Files
mtdb_movie/app/Http/Controllers/PersonCreditsController.php
maher 703f50a09d
Some checks failed
Build / run (push) Has been cancelled
first commit
2025-10-29 11:42:25 +01:00

31 lines
726 B
PHP
Executable File

<?php
namespace App\Http\Controllers;
use App\Actions\People\GetPersonCredits;
use App\Models\Person;
use Common\Core\BaseController;
use Illuminate\Support\Arr;
class PersonCreditsController extends BaseController
{
public function fullTitleCredits(
Person $person,
int $titleId,
string $department,
) {
$this->authorize('show', Person::class);
$credits = app(GetPersonCredits::class)->execute($person, [
'titleId' => $titleId,
]);
$title = Arr::first(
$credits['credits'][$department],
fn($title) => $title['id'] === (int) $titleId,
);
return $this->success(['credits' => $title['episodes']]);
}
}