-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
833a558
commit 788aa34
Showing
10 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace Wimando\LaravelMoodle\Facades; | ||
|
||
use Illuminate\Support\Facades\Facade; | ||
use Wimando\LaravelMoodle\Resources\GroupResource; | ||
use Wimando\LaravelMoodle\Resources\GroupResourceCollection; | ||
use Wimando\LaravelMoodle\Resources\UserResourceCollection; | ||
|
||
/** | ||
* @method static GroupResource getById(int $moodleGroupId) | ||
* @method static GroupResourceCollection getCourseGroups(int $moodleCourseId) | ||
* @method static UserResourceCollection getGroupMembers(int $moodleGroupId) | ||
* @method static GroupResourceCollection delete(array $ids = []) | ||
*/ | ||
class MoodleGroup extends Facade | ||
{ | ||
protected static function getFacadeAccessor(): string | ||
{ | ||
return \Wimando\LaravelMoodle\Services\GroupService::class; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Wimando\LaravelMoodle\Resources; | ||
|
||
use Illuminate\Http\Resources\Json\JsonResource; | ||
|
||
class EnrolmentMethodResource extends JsonResource | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Wimando\LaravelMoodle\Resources; | ||
|
||
use Illuminate\Http\Resources\Json\ResourceCollection; | ||
|
||
class EnrolmentMethodResourceCollection extends ResourceCollection | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Wimando\LaravelMoodle\Resources; | ||
|
||
use Illuminate\Http\Resources\Json\JsonResource; | ||
|
||
class EnrolmentResource extends JsonResource | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Wimando\LaravelMoodle\Resources; | ||
|
||
use Illuminate\Http\Resources\Json\ResourceCollection; | ||
|
||
class EnrolmentResourceCollection extends ResourceCollection | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Wimando\LaravelMoodle\Resources; | ||
|
||
use Illuminate\Http\Resources\Json\JsonResource; | ||
|
||
class UserResource extends JsonResource | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Wimando\LaravelMoodle\Resources; | ||
|
||
use Illuminate\Http\Resources\Json\ResourceCollection; | ||
|
||
class UserResourceCollection extends ResourceCollection | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace Wimando\LaravelMoodle\Services; | ||
|
||
use Illuminate\Support\Arr; | ||
use Wimando\LaravelMoodle\Resources\GroupResource; | ||
use Wimando\LaravelMoodle\Resources\GroupResourceCollection; | ||
use Wimando\LaravelMoodle\Resources\UserResourceCollection; | ||
|
||
class GroupService extends Service | ||
{ | ||
public function getById(int $moodleGroupId): GroupResource | ||
{ | ||
$arguments = ['groupids' => $moodleGroupId]; | ||
|
||
$response = $this->sendRequest('core_group_get_groups', $arguments); | ||
|
||
return GroupResource::make(Arr::first($response)); | ||
} | ||
|
||
public function getCourseGroups(int $moodleCourseId): GroupResourceCollection | ||
{ | ||
$arguments = ['courseid' => $moodleCourseId]; | ||
|
||
$response = $this->sendRequest('core_group_get_course_groups', $arguments); | ||
|
||
return GroupResourceCollection::make($response); | ||
} | ||
|
||
public function getGroupMembers(int $moodleGroupId): UserResourceCollection | ||
{ | ||
$arguments = ['groupids' => [$moodleGroupId]]; | ||
$response = $this->sendRequest('core_group_get_group_members', $arguments); | ||
|
||
return UserResourceCollection::make($response); | ||
} | ||
|
||
public function delete(array $ids = []): GroupResourceCollection | ||
{ | ||
$response = $this->sendRequest('core_group_delete_groups', ['groupids' => $ids]); | ||
|
||
return GroupResourceCollection::make($response); | ||
} | ||
} |