bega updates
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\V1\Story\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class StoryResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->whenHas('id'),
|
||||
'title' => $this->whenHas('title'),
|
||||
'photo' => $this->photo(),
|
||||
'thumbnail' => $this->photo('thumb720x1280'),
|
||||
'expires_at' => $this->expires_at?->toISOString(),
|
||||
];
|
||||
}
|
||||
}
|
||||
26
app/Http/Controllers/Api/V1/Story/StoryController.php
Normal file
26
app/Http/Controllers/Api/V1/Story/StoryController.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\V1\Story;
|
||||
|
||||
use App\Http\Controllers\Api\V1\Story\Resources\StoryResource;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\CMS\Media\Story;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
class StoryController extends Controller
|
||||
{
|
||||
/**
|
||||
* (Media) Active stories.
|
||||
*/
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
return response()->rest(
|
||||
StoryResource::collection(
|
||||
Story::with('media')
|
||||
->active()
|
||||
->ordered()
|
||||
->get()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user