97 lines
3.1 KiB
PHP
97 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Models\CompanyActivity;
|
|
use App\Models\CompanySector;
|
|
use App\Traits\Models\HasCache;
|
|
use App\Traits\Models\HasUwilImages;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Uwil\LaravelActivityLogs\Traits\ActivityLog;
|
|
|
|
/**
|
|
* @property integer $id Id.
|
|
* @property string $name Name of the company.
|
|
* @property string $logo Logo of the company.
|
|
* @property string $responsable Responsable of the company.
|
|
* @property string $url Link the website of the company.
|
|
* @property string $informations Informations of the company.
|
|
* @property string $employees Effectif number of of the company.
|
|
* @property string $latitude Latitude coordination of the company.
|
|
* @property string $longitude Longitude of the company.
|
|
* @property integer $activity_id Activity associated to the company.
|
|
* @property integer|null $sector_id Sector associated to the company.
|
|
* @property string $published Publish status of the company.
|
|
* @property-read \Carbon\Carbon $created_at Created date.
|
|
* @property-read \Carbon\Carbon $updated_at Updated date.
|
|
* @property-read \Illuminate\Support\Carbon $deleted_at Deleted date.
|
|
*/
|
|
class Company extends Model
|
|
{
|
|
use ActivityLog;
|
|
use HasCache;
|
|
use HasFactory;
|
|
use SoftDeletes;
|
|
use HasUwilImages;
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var list<string>
|
|
*/
|
|
protected $fillable = [
|
|
'name',
|
|
'logo',
|
|
'responsable',
|
|
'url',
|
|
'informations',
|
|
'employees',
|
|
'latitude',
|
|
'longitude',
|
|
'activity_id',
|
|
'sector_id',
|
|
'published',
|
|
];
|
|
|
|
/**
|
|
* The attributes that should be cast.
|
|
*
|
|
* @var array<string, string>
|
|
*/
|
|
protected $casts = [
|
|
'published' => 'boolean',
|
|
];
|
|
|
|
/**
|
|
* Relations should be included in the cache.
|
|
*
|
|
* @var list<string>
|
|
*/
|
|
protected static $cacheRelations = [
|
|
'companyActivity',
|
|
];
|
|
|
|
// * RELATIONSHIPS
|
|
|
|
/**
|
|
* Get the activity for this company.
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\App\Models\CompanyActivity,$this>
|
|
*/
|
|
public function companyActivity(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
{
|
|
return $this->belongsTo(CompanyActivity::class, 'activity_id');
|
|
}
|
|
|
|
/**
|
|
* Get the sector for this company.
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\App\Models\CompanySector,$this>
|
|
*/
|
|
public function companySector(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
{
|
|
return $this->belongsTo(CompanySector::class, 'sector_id');
|
|
}
|
|
}
|