![]() 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\Models\BaseModel; use Corals\Foundation\Transformers\PresentableTrait; use Corals\Modules\Medad\Constants\CompanyTypeConstants; use Corals\Modules\Medad\Traits\CanBeNotified; use Corals\Modules\Medad\Traits\ModelUsersTrait; use Corals\Modules\Utility\Models\Address\Location; use Corals\User\Models\User; use Illuminate\Support\Str; use Spatie\Activitylog\Traits\LogsActivity; class Project extends BaseModel { use PresentableTrait, LogsActivity, ModelUsersTrait, CanBeNotified; protected $formModalConfig = ['size' => 'modal-lg']; /** * Model configuration. * @var string */ public $config = 'medad.models.project'; protected $table = 'medad_projects'; protected $casts = [ 'properties' => 'json', ]; protected $guarded = ['id']; public function projectManager() { return $this->belongsTo(User::class, 'manager_id'); } public function projectCompanies() { return $this->belongsToMany(Company::class, 'medad_company_project', 'project_id', 'company_id') ->withTimestamps() ->withPivot(['properties', 'relation_type']); } public function projectSuppliers() { return $this->projectCompanies()->where('relation_type', CompanyTypeConstants::SUPPLIER); } public function branch() { return $this->belongsTo(Branch::class); } public function manager() { return $this->belongsTo(User::class); } public function location() { return $this->belongsTo(Location::class); } protected function getResourceRouteFor($action, $id = null) { $config = config($this->config); $route = Str::replaceLast('index', $action, $config['resource_route']); if ($action == 'create') { return route($route, ['company' => $this->branch->company->hashed_id, 'branch' => $this->branch->hashed_id]); } else { return route($route, [ 'company' => $this->branch->company->hashed_id, 'branch' => $this->branch->hashed_id, $config['relation'] => $id ]); } } public function getNotifiables() { return $this->projectManager; } }