![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/medad.corals.io/Corals/modules/Medad/Models/ |
<?php namespace Corals\Modules\Medad\Models; use Corals\Foundation\Transformers\PresentableTrait; use Illuminate\Database\Eloquent\Builder; use Spatie\Activitylog\Traits\LogsActivity; class Branch extends CompanyModel { use PresentableTrait, LogsActivity; /** * The "booted" method of the model. * * @return void */ protected static function booted() { static::addGlobalScope('parent', function (Builder $builder) { $builder->whereNotNull('medad_companies.parent_id'); }); } /** * Model configuration. * @var string */ public $config = 'medad.models.branch'; protected $appends = ['is_main_branch']; public function company() { return $this->belongsTo(Company::class, 'parent_id', 'id'); } public function getIsMainBranchAttribute() { return $this->id == $this->parent_id; } public function getNotifiables() { return $this->admins->merge($this->users); } }