91 lines
1.9 KiB
PHP
91 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
|
|
|
class RahdariPoint extends Model
|
|
{
|
|
|
|
public static function boot()
|
|
{
|
|
parent::boot();
|
|
|
|
self::creating(function($model){
|
|
});
|
|
|
|
self::created(function($model){
|
|
auth()->user()->addActivityComplete(1020,$model);
|
|
});
|
|
|
|
self::updating(function($model){
|
|
auth()->user()->addActivityComplete(1021,$model);
|
|
});
|
|
|
|
self::updated(function($model){
|
|
});
|
|
|
|
self::deleting(function($model){
|
|
auth()->user()->addActivityComplete(1022,$model);
|
|
});
|
|
|
|
self::deleted(function($model){
|
|
});
|
|
}
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $fillable = [
|
|
'province_name',
|
|
'city_name',
|
|
'province_id',
|
|
'city_id',
|
|
'name',
|
|
'status',
|
|
'type',
|
|
'type_fa',
|
|
'team_num',
|
|
'staff_num',
|
|
'phone',
|
|
'responsible_name',
|
|
'responsible_mobile',
|
|
'successor_name',
|
|
'successor_mobile',
|
|
'machines_light',
|
|
'machines_sheavy',
|
|
'machines_heavy',
|
|
'code',
|
|
'lat',
|
|
'lng',
|
|
'lat_from',
|
|
'lng_from',
|
|
'geometry',
|
|
'color',
|
|
'lat_to',
|
|
'lng_to',
|
|
'updated_at_fa',
|
|
];
|
|
|
|
public function files(): MorphMany
|
|
{
|
|
return $this->morphMany('App\Models\PointFile', 'point_fileable');
|
|
}
|
|
|
|
public function rahdariPointHistories(): HasMany
|
|
{
|
|
return $this->hasMany('App\Models\RahdariPointHistory', 'point_id');
|
|
}
|
|
|
|
protected function area(): Attribute
|
|
{
|
|
return Attribute::make(
|
|
get: fn($value) => json_decode($value)
|
|
);
|
|
}
|
|
} |