- Complete GGZ Ecademy Laravel backend application - RESTful API for learning products, members, filters - Authentication and authorization system - Database migrations and seeders - Custom CRUD generator commands - Email notification system - Integration with frontend applications
This commit is contained in:
26
app/Http/Resources/FiltersResource.php
Normal file
26
app/Http/Resources/FiltersResource.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class FiltersResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'title' => $this->title,
|
||||
'multiple' => $this->type,
|
||||
'items' => $this->whenLoaded('items'),
|
||||
'items_count' => $this->items ? $this->items_count : null,
|
||||
'slug' => $this->slug,
|
||||
];
|
||||
}
|
||||
}
|
||||
136
app/Http/Resources/LearningProductResource.php
Normal file
136
app/Http/Resources/LearningProductResource.php
Normal file
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class LearningProductResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
|
||||
$filtersGrouped = [];
|
||||
|
||||
// merging accreditation filters to allow the filtering in frontend
|
||||
if (isset($this->accreditations)) {
|
||||
|
||||
foreach ($this->accreditations as $accreditation) {
|
||||
|
||||
foreach ($accreditation->filters as $filter) {
|
||||
|
||||
$filtersGrouped[$filter->filter_item->filter_id][] = $filter->filter_item_id;
|
||||
// To avoid double values
|
||||
$filtersGrouped[$filter->filter_item->filter_id] = array_unique($filtersGrouped[$filter->filter_item->filter_id]);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (isset($this->filters)) {
|
||||
|
||||
foreach ($this->filters as $filter) {
|
||||
|
||||
$filtersGrouped[$filter->filter_item->filter_id][] = $filter->filter_item_id;
|
||||
// To avoid double values
|
||||
$filtersGrouped[$filter->filter_item->filter_id] = array_unique($filtersGrouped[$filter->filter_item->filter_id]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$filtersFlattened = [
|
||||
'status' => null,
|
||||
'product_type' => null,
|
||||
'theme' => null,
|
||||
'course' => null,
|
||||
];
|
||||
|
||||
foreach ($filtersFlattened as $title => $value) {
|
||||
|
||||
if (isset($this->filters)) {
|
||||
foreach ($this->filters as $filter) {
|
||||
if (
|
||||
$filter->filter_item->filter->title === $title
|
||||
&& $filter->filter_item->title
|
||||
) {
|
||||
$filtersFlattened[$title][] = $filter->filter_item->title;
|
||||
}
|
||||
}
|
||||
if ($filtersFlattened[$title]) {
|
||||
sort($filtersFlattened[$title]);
|
||||
$filtersFlattened[$title] = implode(", ", $filtersFlattened[$title]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'parent_id' => $this->parent_id,
|
||||
'title' => $this->title,
|
||||
'description' => $this->description,
|
||||
'video' => $this->video,
|
||||
'code' => $this->code,
|
||||
'published' => $this->published,
|
||||
'lead_time' => $this->lead_time,
|
||||
'short_description' => $this->short_description,
|
||||
'learning_goals' => $this->learning_goals,
|
||||
'review' => $this->review,
|
||||
'certification' => $this->certification,
|
||||
'extra_information' => $this->extra_information,
|
||||
'target_audience' => $this->target_audience,
|
||||
'quality_standards' => $this->quality_standards,
|
||||
'in_the_picture' => $this->in_the_picture,
|
||||
'in_the_picture_start' => $this->in_the_picture_start,
|
||||
'in_the_picture_end' => $this->in_the_picture_end,
|
||||
'owner' => $this->owner,
|
||||
'partner' => $this->partner,
|
||||
'supplier' => $this->supplier,
|
||||
'contract_agreements' => $this->contract_agreements,
|
||||
'draft' => $this->draft ? $this->draft : null,
|
||||
'slug' => $this->slug,
|
||||
'seo_title' => $this->seo_title,
|
||||
'meta_description' => $this->meta_description,
|
||||
'url' => $this->url,
|
||||
'cover' => [
|
||||
'full' => $this->getFirstMediaUrl('learning_products_covers'),
|
||||
'thumb' => $this->getFirstMediaUrl('learning_products_covers', 'thumb')
|
||||
],
|
||||
'tile' => [
|
||||
'full' => $this->getFirstMediaUrl('learning_products_tiles'),
|
||||
'thumb' => $this->getFirstMediaUrl('learning_products_tiles', 'thumb')
|
||||
],
|
||||
'prognosis_members' => $this->prognosis_members,
|
||||
'prognosis_attendees' => $this->prognosis_attendees,
|
||||
'sharepoint_link' => $this->sharepoint_link,
|
||||
'support_link' => $this->support_link,
|
||||
'support_tickets_link' => $this->support_tickets_link,
|
||||
'filters' => $this->whenLoaded('filters'),
|
||||
'accreditations' => $this->whenLoaded('accreditations'),
|
||||
'notifications' => $this->whenLoaded('notifications'),
|
||||
'filtersGrouped' => (object) $filtersGrouped,
|
||||
'filterItemsSelected' => Arr::flatten(get_object_vars((object) $filtersGrouped)),
|
||||
'versions' => $this->whenLoaded('versions'),
|
||||
'synonyms' => $this->synonyms,
|
||||
'for_members' => $this->for_members,
|
||||
'third_party_training' => $this->third_party_training,
|
||||
'voor_opleiders' => $this->voor_opleiders,
|
||||
|
||||
// Returns a concatenated string with all the "theme" titles attached
|
||||
'theme' => $filtersFlattened['theme'],
|
||||
'status' => $filtersFlattened['status'],
|
||||
'course' => $filtersFlattened['course'],
|
||||
'product_type' => $filtersFlattened['product_type'],
|
||||
|
||||
'created_at' => $this->created_at->toDateTimeString(),
|
||||
'updated_at' => $this->updated_at->toDateTimeString(),
|
||||
'deleted_at' => $this->deleted_at ? $this->deleted_at->toDateTimeString() : null,
|
||||
];
|
||||
}
|
||||
}
|
||||
70
app/Http/Resources/MemberResource.php
Normal file
70
app/Http/Resources/MemberResource.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class MemberResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'slug' => $this->slug,
|
||||
'type' => $this->type,
|
||||
'branch_id' => $this->branch_id,
|
||||
'main_branch' => $this->main_branch->title ?? null,
|
||||
'informal_name' => $this->informal_name,
|
||||
'formal_name' => $this->formal_name,
|
||||
'kvk_number' => $this->kvk_number,
|
||||
'website' => $this->website,
|
||||
'logo' => [
|
||||
'full' => $this->getFirstMediaUrl('members_logos'),
|
||||
'thumb' => $this->getFirstMediaUrl('members_logos', 'thumb')
|
||||
],
|
||||
'show_on_website' => $this->show_on_website,
|
||||
'helpdesk_department' => $this->helpdesk_department,
|
||||
'helpdesk_contact_person' => $this->helpdesk_contact_person,
|
||||
'helpdesk_email' => $this->helpdesk_email,
|
||||
'helpdesk_phone' => $this->helpdesk_phone,
|
||||
'info_department' => $this->info_department,
|
||||
'info_contacteperson' => $this->info_contacteperson,
|
||||
'info_email' => $this->info_email,
|
||||
'info_phone' => $this->info_phone,
|
||||
'info_address' => $this->info_address,
|
||||
'info_housenumber' => $this->info_housenumber,
|
||||
'info_postal' => $this->info_postal,
|
||||
'info_city' => $this->info_city,
|
||||
'info_country' => $this->info_country,
|
||||
'info_link' => $this->info_link,
|
||||
'more_info_link' => $this->more_info_link,
|
||||
|
||||
'summaries' => $this->whenLoaded('summaries'),
|
||||
'addresses' => $this->whenLoaded('addresses'),
|
||||
'contacts' => $this->whenLoaded('contacts'),
|
||||
'contributions' => $this->whenLoaded('contributions'),
|
||||
'management_links' => $this->whenLoaded('management_links'),
|
||||
'sub_branches' => $this->whenLoaded('sub_branches'),
|
||||
'user_ids' => $this->relationLoaded('users')
|
||||
? $this->users->pluck('id')
|
||||
: [],
|
||||
|
||||
'revision' => $this->whenLoaded('revision'),
|
||||
|
||||
'start_membership' => $this->start_membership,
|
||||
'end_membership' => $this->end_membership,
|
||||
'contribution' => $this->contribution,
|
||||
'invoice_number' => $this->invoice_number,
|
||||
|
||||
'created_at' => $this->created_at->toDateTimeString(),
|
||||
'updated_at' => $this->updated_at ? $this->updated_at->toDateTimeString() : null,
|
||||
'deleted_at' => $this->deleted_at ? $this->deleted_at->toDateTimeString() : null,
|
||||
];
|
||||
}
|
||||
}
|
||||
28
app/Http/Resources/PageResource.php
Normal file
28
app/Http/Resources/PageResource.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class PageResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'title' => $this->title,
|
||||
'subtitle' => $this->subtitle,
|
||||
'published_at' => $this->updated_at->toDateTimeString(),
|
||||
'created_at' => $this->updated_at->toDateTimeString(),
|
||||
'updated_at' => $this->created_at->toDateTimeString(),
|
||||
'slug' => $this->slug,
|
||||
'components' => $this->whenLoaded('components'),
|
||||
];
|
||||
}
|
||||
}
|
||||
37
app/Http/Resources/UserLoggedResource.php
Normal file
37
app/Http/Resources/UserLoggedResource.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class UserLoggedResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'first_name' => $this->first_name,
|
||||
'last_name' => $this->last_name,
|
||||
'fullName' => $this->fullName,
|
||||
'email' => $this->email,
|
||||
'created_at' => $this->updated_at->toDateTimeString(),
|
||||
'updated_at' => $this->created_at->toDateTimeString(),
|
||||
'last_login_at' => $this->last_login_at,
|
||||
'logged_at' => $this->logged_at,
|
||||
'roles' => $this->roles,
|
||||
'isMemberEditor' => $this->isMemberEditor,
|
||||
'image' => [
|
||||
'full' => $this->getFirstMediaUrl('profile_pics'),
|
||||
'thumb' => $this->getFirstMediaUrl('profile_pics', 'thumb')
|
||||
],
|
||||
'notifications' => $this->when($this->notifications, $this->notifications),
|
||||
'membersManagedCount' => $this->when($this->members, $this->members->count()),
|
||||
];
|
||||
}
|
||||
}
|
||||
33
app/Http/Resources/UserResource.php
Normal file
33
app/Http/Resources/UserResource.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class UserResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'first_name' => $this->first_name,
|
||||
'last_name' => $this->last_name,
|
||||
'fullName' => $this->fullName,
|
||||
'email' => $this->email,
|
||||
'created_at' => $this->updated_at->toDateTimeString(),
|
||||
'updated_at' => $this->created_at->toDateTimeString(),
|
||||
'roles' => $this->roles,
|
||||
'isMemberEditor' => $this->isMemberEditor,
|
||||
'image' => [
|
||||
'full' => $this->getFirstMediaUrl('profile_pics'),
|
||||
'thumb' => $this->getFirstMediaUrl('profile_pics', 'thumb')
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
22
app/Http/Resources/UsersList.php
Normal file
22
app/Http/Resources/UsersList.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class UsersList extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'fullName' => $this->fullName,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user