Paillasse/portail/app/Http/Resources/Api/V1/CoursResource.php

24 lines
554 B
PHP
Raw Permalink Normal View History

<?php
namespace App\Http\Resources\Api\V1;
use App\Models\Cours;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
/** @mixin Cours */
class CoursResource extends JsonResource
{
/**
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'identifiant' => $this->identifiant,
'titre' => $this->titre,
'contenu_markdown' => $this->when($request->routeIs('api.v1.cours.show'), $this->contenu_markdown),
];
}
}