All notable changes to MsGraph
will be documented in this file.
- Everything
- added 2 traits
- Emails - methods for listing emails and attachments and sending, replying and forwarding
- Contacts - List all contacts
- fixed migration name and path
- corrected config publish path
Added MsGraphAuthenticated to routes to ensure the user is authenticated id:
Route::group(['middleware' => ['web', 'MsGraphAuthenticated'], function()
Added method getTokenData($id) to return the model object based on the matching user_id from $id
public function getTokenData($id = null)
{
$id = ($id) ? $id : auth()->id();
return MsGraphToken::where('user_id', $id)->first();
}
Fixed connect method authenticating, now accepts an optional $id defaults to logged in user when not passed directly.
Added traits:
- Drive
- ToDo
Updated traits to support correct paging, each trait should return an array containing the total records (where available), top, skip and count keys.
Added new traits:
- Calendar
- CalendarEvents
- Events
Renamed all methods to be action followed by name ie getEmails
Renamed repo to daveismyname/laravel-msgraph
Fixed install error
Corrected path in composer.json stopping installation.
Added ability to login as a tenant by using MsGraphAdmin
Renamed repo to daveismyname/laravel-microsoft-graph Added tenency support Removed traits and added classes in resources instead
Renamed repo to dcblogdev/laravel-microsoft-graph
Added support for Laravel 7
Calling the API with the id
When calling the connect-method with explicit id it would fail trying to retrieve the users email address. This issue is fixed by calling the API with the id.
added support for Laravel 8
Laravel 8 and Guzzle 7 support
Guzzle has been upgraded from version 6 to 7 and Laravel 8 (illuminate/support) has been added.
Base url has also changed from the /beta endpoing to 1.0
https://graph.microsoft.com/v1.0/
Support for Guzzle 6 and 7
Added support for both Guzzle 6 and 7 since older versions of Laravel required Guzzle 6.
patch for guzzle 6/7
supports login ability
Added new methods: isConnected() and disconnect() fires an event when a user logs in config uses tenant id for authorise urls when set in .env added a publishing option for listeners added an event NewMicrosoft365SignInEvent that fires on login.
Fix issue when connecting with specified ID
Merge pull request #14 from stromgren/explicit-id
Fix issue when connecting with specified ID
added file methods
Added methods:
List files and folders
MsGraph::files()->getFiles($path = null, $order = 'asc');
List drive
MsGraph::files()->getDrive();
List drives
MsGraph::files()->getDrives();
Search items
MsGraph::files()->search($term);
Download file by id
MsGraph::files()->downloadFile($id)
Delete file by id
MsGraph::files()->deleteFile($id)
Create folder pass the folder and the path where the folder will be created if no path is provided the root is used.
MsGraph::files()->createFolder($name, $path = null)
Get file/folder item by id
MsGraph::files()->getItem($id)
Rename file/folder pass the new name and the id
MsGraph::files()->rename($name, $id)
Upload file passes the name and the uploadPath (where the file is on your server) and the path to where the file will be stored if no path is provided the root is used.
MsGraph::files()->upload($name, $uploadPath, $path = null)
Changed files to support passing the prefix to the paths such as me or groups/$groupId or sites.
Example
//set a custom prefix to a set group
MsGraph::files()->getFiles($this->path, "groups/$groupId");
//use the default (me)
MsGraph::files()->getFiles($this->path);
Added classes for MsGraphAdmin for working with Calendars and Events
Calendar Events
MsGraphAdmin::calendarEvents()->userid($userId)->get();
MsGraphAdmin::calendarEvents()->userid($userId)->find($calendarId, $eventId);
MsGraphAdmin::calendarEvents()->userid($userId)->store($calendarId, $data);
Calendars
MsGraphAdmin::calendars()->userid($userId)->get();
MsGraphAdmin::calendars()->userid($userId)->find($eventId);
MsGraphAdmin::calendars()->userid($userId)->store($data);
MsGraphAdmin::calendars()->userid($userId)->update($data);
Events
MsGraphAdmin::events()->userid($userId)->get();
MsGraphAdmin::events()->userid($userId)->find($eventId);
MsGraphAdmin::events()->userid($userId)->store($data);
MsGraphAdmin::events()->userid($userId)->update($data);
MsGraphAdmin::events()->userid($userId)->delete($data);
Changed getPagination() to return array containing only previous and next page numbers.
This method needs the data but also the total number of records, the limit ($top) and the offset ($skip)
$limit = 5;
$skip = request('next', 0);
$messageQueryParams = [
"\$orderby" => "displayName",
"\$count" => "true",
"\$skip" => $skip,
"\$top" => $limit,
];
$contacts = MsGraph::get('me/contacts?'.http_build_query($messageQueryParams));
$total = $contacts['@odata.count'] ?? 0;
$response = MsGraph::getPagination($contacts, $total, $limit, $skip);
$previous = $response['previous'];
$next = $response['next'];
The in a view the previous and next links can be displayed:
@if (request('next') > 0)
<a href='{{ url()->current().'?next='.$previous }}'>Previous Page</a>
@endif
@if ($next != 0)
<a href='{{ url()->current().'?next='.$next }}'>Next Page</a>
@endif
added support for Laravel 9
Added files import for MsGraphAdmin
- Test foundation using PestPHP
- PHP code sniffer fixer and style config
MSGRAPH_DB_CONNECTION
to be mysql to use a connection called mysql- Store name is email cannot be found when connecting
- Changed responses so if the data is json it gets decoded otherwise the raw body is returned
Msgraph::emails->get($folderId, $params)
returns error when mailbox folder not found
- used MsGraphAdmin instead of MsGraph in admin files resource
- added commands
msgraphadmin:keep-alive
andmsgraph:keep-alive
to allow refresh tokens to be automated by running these commands on a schedule - added support in Files.php to support replace/rename behavior on
createFolder
and fileupload
functions. Default behavior is to rename.
Usage for createFolder:
MsGraph::files()->createFolder($name, $path, $type = 'me', $behavior='rename')
Where $behavior is either rename or replace
Usage for upload:
MsGraph::files()->upload($name, $uploadPath, $path=null, $type='me',$behavior='rename')
Where $behavior is either rename or replace
- added support for Laravel 10
- changed migration to anonymous migration
- @ChrisToxz Rewrote MsGraphAdmin token methods 44
- MsGraphAdmin::connect redirects by default add false to disable redirecting.
- Changed MsGraph Listener to store a token once authenticated directly
- Re-wrote a lot of the internal workings of MsGraph, no user land changes required apart from the Listener has changed.
- Added tests for both MsGraph and MsGraphAdmin
- Corrected refresh tokens after they expire
- Stopped an infinite loop when a token needs to be refreshed
- Stopped duplicating users when using a listener
- Stopped token getting deleted on logout
- Stopped token getting overwritten when another user logs in
- Added
tenantId
to config file to allow the tenantId to be retrievable - Added package shitware-ltd/flysystem-msgraph into this package to allow using a files flysystem driver
- Added page to the docs for the file system
- Removed unused imports from testcase
- Added method setApiVersion to set API version on call defaults to 1.0
MsGraph::setApiVersion('beta')->get('me')
- Added pagination helper to build pages from a set number of records, for internal use
- Added TaskLists resource class for working with task lists
- Updated contacts get method to use pagination of the contacts. Sets default per page to 25 contacts
- Updated Tasks resource class for working with tasks
- Add ability to override the User model by setting
setUserModel($model)
when usingMsGraph
class
- Changed migrations to not run migrations automatically
- Removed package level migrations, using src migrations instead
See https://github.com/dcblogdev/laravel-microsoft-graph/releases for all releases