Files
movies/app/Livewire/ShowPage/Tabs/Crew.php
T
2025-02-10 01:58:12 +02:00

38 lines
934 B
PHP

<?php
namespace App\Livewire\ShowPage\Tabs;
use App\Models\Person;
use App\Models\Show;
use Livewire\Component;
class Crew extends Component
{
public $show;
public $peopleByDepartment;
public function render()
{
return view('livewire.show-page.tabs.crew');
}
public function mount()
{
$this->show = Show::with('castList')->where('id', $this->show->id)->first();
$peopleByDepartment = [];
foreach ($this->show->crewList as $castMember) {
if (!isset($peopleByDepartment[$castMember->pivot->department])) {
$peopleByDepartment[$castMember->pivot->department] = [];
}
$peopleByDepartment[$castMember->pivot->department][] = [
Person::find($castMember->pivot->person_id),
$castMember->pivot->job,
];
}
$this->peopleByDepartment = $peopleByDepartment;
}
}