ldc-jeusselin/app/Models/BusinessSector.php
Olivier Legat 37f5807f11 update integration
nos metiers -  Work in progress (interrompu)
2021-02-18 17:29:54 +01:00

37 lines
754 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class BusinessSector extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name',
'order',
'parent_id',
];
public function employees()
{
return $this->belongsToMany(Employees::class, 'sectors_employees', 'business_sector_id', 'employee_id')->orderBy('order', 'ASC');
}
public function parent()
{
return $this->hasOne(self::class,'id','parent_id');
}
public function children()
{
return $this->hasMany(self::class,'parent_id','id');
}
}