1. Go to this page and download the library: Download mabrouk/project-setting library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mabrouk / project-setting example snippets
artisan setting:install
namespace Mabrouk\ProjectSetting\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class ProjectSettingGroupResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->name,
'permissions' => ProjectSettingResource::collection($this->permissions),
];
}
}
namespace Mabrouk\ProjectSetting\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class ProjectSettingGroupSimpleResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->name,
];
}
}
namespace Mabrouk\ProjectSetting\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class ProjectSettingResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->display_name,
'selected' => $this->isSelected,
'project_setting_group' => new ProjectSettingGroupSimpleResource($this->projectSettingGroup),
'sub_permissions' => SubProjectSettingResource::collection($this->subProjectSettings),
];
}
}
namespace Mabrouk\ProjectSetting\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class SubProjectSettingResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->display_name,
'selected' => $this->isSelected,
];
}
}
namespace Mabrouk\ProjectSetting\Http\Resources;
use Mabrouk\ProjectSetting\Models\ProjectSettingGroup;
use Illuminate\Http\Resources\Json\JsonResource;
class RoleResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->name,
'permission_groups' => ProjectSettingGroupResource::collection(ProjectSettingGroup::all()),
];
}
}
namespace Mabrouk\ProjectSetting\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class RoleSimpleResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->name,
'description' => $this->description,
];
}
}
project_settings.php
bash
php artisan setting:install
config/project_settings.php
project_settings.php
bash
php artisan config:cache
bash
php artisan route:list
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.