Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Microsoft Graph Laravel Package

microsoft/microsoft-graph

View on GitHub
Deep Wiki
Context7

1. LIST ALL DRIVES (GET /drives)

$graphServiceClient = new GraphServiceClient($tokenRequestContext);

try {
    $drives = $graphServiceClient->drives()->get()->wait();
    if ($drives && $drives->getValue()) {
        foreach ($drives->getValue() as $drive) {
            echo "Drive ID: {$drive->getId()}<br>";
            echo "Drive Type: {$drive->getDriveType()}<br>";
            echo "Drive Name: {$drive->getName()}<br>";
            echo "Drive Description: {$drive->getDescription()}<br>";
            echo "Drive Web URL: {$drive->getWebUrl()}<br><br>";
        }
    }
} catch (ApiException $ex) {
    echo "Error: " . $ex->getResponseStatusCode() . "\n";
    echo "Error: " .$ex->getError()->getMessage();";
}

2. GET DRIVE BY ID (GET /drives/{id})

$driveId = "DRIVE-ID"; 

try {
    $drive = $graphServiceClient->drives()->byDriveId($driveId)->get()->wait();
    if ($drive) {
        echo "Drive ID: {$drive->getId()}<br>";
        echo "Drive Type: {$drive->getDriveType()}<br>";
        echo "Drive Name: {$drive->getName()}<br>";
        echo "Drive Description: {$drive->getDescription()}<br>";
        echo "Drive Web URL: {$drive->getWebUrl()}<br>";
    }
} catch (ApiException $ex) {
    echo "Error: " . $ex->getResponseStatusCode() . "\n";
    echo "Error: " .$ex->getError()->getMessage();";
}

3. LIST ALL THE ITEMS IN A DRIVE (GET /drives/{id}/items)

$graphServiceClient = new GraphServiceClient($tokenRequestContext);

$driveId = "DRIVE-ID"; 

try {
    $requestConfig = new ItemsRequestBuilderGetRequestConfiguration();
    $requestConfig->queryParameters = ItemsRequestBuilderGetRequestConfiguration::createQueryParameters();
    $requestConfig->queryParameters->filter = "startswith(name, 'B')"; 

    $items = $graphServiceClient->drives()->byDriveId($driveId)->items()->get($requestConfig)->wait();
    if ($items && $items->getValue()) {
        foreach ($items->getValue() as $item) {
            echo "Item ID: {$item->getId()}<br>";
            echo "Item Name: {$item->getName()}<br>";
            echo "Item Size: {$item->getSize()}<br>";
            echo "Item Folder: " . json_encode($item->getFolder()) . "<br>";
            echo "Item File: " . json_encode($item->getFile()) . "<br><br>";
        }
    }
} catch (ApiException $ex) {
   echo "Error: " . $ex->getResponseStatusCode() . "\n";
    echo "Error: " .$ex->getError()->getMessage();";
}

4. GET AN ITEM IN THE DRIVE (GET /drives/{id}/items/{id})

$graphServiceClient = new GraphServiceClient($tokenRequestContext);

$driveId = "DRIVE-ID"; 

try {
    $items = $graphServiceClient->drives()->byDriveId($driveId)->items()->get()->wait();
    if ($items && $items->getValue()) {
        foreach ($items->getValue() as $item) {
            echo "Item ID: {$item->getId()}<br>";
            echo "Item Name: {$item->getName()}<br>";
            echo "Item Size: {$item->getSize()}<br>";
            echo "Item Folder: " . json_encode($item->getFolder()) . "<br>";
            echo "Item File: " . json_encode($item->getFile()) . "<br><br>";
        }
    }
} catch (ApiException $ex) {
    echo "Error: " . $ex->getResponseStatusCode() . "\n";
    echo "Error: " .$ex->getError()->getMessage();";
}

5. GET THE ROOT FOLDER OF THE DRIVE (GET /drives/{id}/root)

$graphServiceClient = new GraphServiceClient($tokenRequestContext);

$driveId = "DRIVE-ID"; // Replace with the actual drive ID

try {
    $root = $graphServiceClient->drives()->byDriveId($driveId)->root()->get()->wait();
    if ($root) {
        echo "Root ID: {$root->getId()}<br>";
        echo "Root Name: {$root->getName()}<br>";
        echo "Folder Child Count: " . ($root->getFolder() ? $root->getFolder()->getChildCount() : 'N/A') . "<br>";
        echo "Root: " . json_encode($root->getRoot()) . "<br>";
        echo "Root Size: {$root->getSize()}<br>";
    }
} catch (ApiException $ex) {
    echo "Error: " . $ex->getResponseStatusCode() . "\n";
    echo "Error: " .$ex->getError()->getMessage();";
}

6. GET ITEMS IN THE ROOT FOLDER OF THE DRIVE (GET drives/{id}/items/root/children)

$graphServiceClient = new GraphServiceClient($tokenRequestContext);

$driveId = "DRIVE-ID";

try {
    $items = $graphServiceClient->drives()->byDriveId($driveId)->items()->byDriveItemId('root')->children()->get()->wait();
    if ($items && $items->getValue()) {
        foreach ($items->getValue() as $item) {
            echo "Item ID: {$item->getId()}<br>";
            echo "Item Name: {$item->getName()}<br>";
            echo "Item Size: {$item->getSize()}<br>";
            echo "Item Folder: " . json_encode($item->getFolder()) . "<br>";
            echo "Item File: " . json_encode($item->getFile()) . "<br><br>";
        }
    }
} catch (ApiException $ex) {
    echo "Error: " . $ex->getResponseStatusCode() . "\n";
    echo "Error: " .$ex->getError()->getMessage();";
}
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
make-dev/orca
dmstr/symfony-system-resources-bundle
dmstr/symfony-job-queue-bundle
dmstr/openapi-json-schema-bundle
dmstr/keycloak-security-bundle
dmstr/doctrine-audit-log-bundle
dmstr/api-platform-utils-bundle
dmstr/api-configuration-bundle
chrisdev/ux-components
baks-dev/finances
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle