update deploy
This commit is contained in:
29
app/Http/Resources/RoleResource.php
Normal file
29
app/Http/Resources/RoleResource.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
/**
|
||||
* @mixin Role
|
||||
*/
|
||||
class RoleResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'guard_name' => $this->guard_name,
|
||||
'permissions' => $this->whenLoaded('permissions', fn () => $this->permissions->pluck('name')),
|
||||
'users_count' => $this->whenCounted('users'),
|
||||
'created_at' => $this->created_at?->toISOString(),
|
||||
'updated_at' => $this->updated_at?->toISOString(),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user