1 | <?php |
||
2 | |||
3 | namespace App\Tables\Builders; |
||
4 | |||
5 | use App\Family; |
||
6 | use Illuminate\Database\Eloquent\Builder; |
||
7 | use LaravelEnso\Tables\Contracts\Table; |
||
8 | |||
9 | class FamilyTable implements Table |
||
10 | { |
||
11 | protected const TemplatePath = __DIR__.'/../Templates/families.json'; |
||
12 | |||
13 | public function query(): Builder |
||
14 | { |
||
15 | return Family::leftJoin('people as husband', function ($join) { |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
16 | $join->on('husband.id', '=', 'families.husband_id'); |
||
17 | }) |
||
18 | ->leftJoin('people as wife', function ($join) { |
||
19 | $join->on('wife.id', '=', 'families.wife_id'); |
||
20 | }) |
||
21 | ->select(\DB::raw(' |
||
22 | families.id, families.id as "dtRowId", families.description as description, husband.name as husband_name, |
||
23 | wife.name as wife_name, families.is_active |
||
24 | ')); |
||
25 | } |
||
26 | |||
27 | public function templatePath(): string |
||
28 | { |
||
29 | return static::TemplatePath; |
||
30 | } |
||
31 | } |
||
32 |