modularsoftware /
genealogy
| 1 | <?php |
||
| 2 | |||
| 3 | namespace App\Tables\Builders; |
||
| 4 | |||
| 5 | use App\Person; |
||
| 6 | use App\Traits\ConnectionTrait; |
||
| 7 | use Illuminate\Database\Eloquent\Builder; |
||
| 8 | use LaravelEnso\Tables\Contracts\Table; |
||
| 9 | |||
| 10 | class PersonTable extends \LaravelEnso\People\Tables\Builders\PersonTable |
||
| 11 | { |
||
| 12 | use ConnectionTrait; |
||
| 13 | |||
| 14 | protected const TemplatePath = __DIR__.'/../Templates/people.json'; |
||
| 15 | |||
| 16 | public function query(): Builder |
||
| 17 | { |
||
| 18 | $conn = $this->getConnection(); |
||
| 19 | $db = $this->getDB(); |
||
|
0 ignored issues
–
show
Unused Code
introduced
by
Loading history...
|
|||
| 20 | |||
| 21 | return Person::on($conn)->selectRaw(' |
||
|
0 ignored issues
–
show
|
|||
| 22 | people.id |
||
| 23 | , people.title, people.givn, people.surn, people.appellative, people.email, people.phone, |
||
| 24 | people.birthday, people.deathday, CASE WHEN users.id is null THEN 0 ELSE 1 END as "user", |
||
| 25 | companies.name as company, people.created_at |
||
| 26 | ')->leftJoin('users', 'people.id', '=', 'users.person_id') |
||
| 27 | ->leftJoin( |
||
| 28 | 'company_person', |
||
| 29 | fn ($join) => $join |
||
| 30 | ->on('people.id', '=', 'company_person.person_id') |
||
| 31 | ->where('company_person.is_main', true) |
||
| 32 | )->leftJoin('companies', 'company_person.company_id', 'companies.id'); |
||
| 33 | } |
||
| 34 | |||
| 35 | public function templatePath(): string |
||
| 36 | { |
||
| 37 | return static::TemplatePath; |
||
| 38 | } |
||
| 39 | } |
||
| 40 |