54 lines
1.1 KiB
PHP
54 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Constant\Constant;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use App\Models\Traits\SantLocation\Relationships\SantLocationRelationships;
|
|
|
|
class SantLocation extends Model
|
|
{
|
|
use HasFactory, SantLocationRelationships;
|
|
|
|
protected $appends = ['created_ago', 'updated_ago'];
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $fillable = [
|
|
'sant_id',
|
|
'sangh_id',
|
|
'type',
|
|
'location',
|
|
'latitude',
|
|
'longitude',
|
|
'created_by',
|
|
'updated_by'
|
|
];
|
|
|
|
protected $guarded = [
|
|
'id',
|
|
];
|
|
|
|
/**
|
|
* Returns model in days since created_at.
|
|
*/
|
|
public function getCreatedAgoAttribute() {
|
|
return $this->created_at->diffForHumans();
|
|
}
|
|
|
|
/**
|
|
* Returns model in days since updated_at.
|
|
*/
|
|
public function getUpdatedAgoAttribute() {
|
|
if ($this->updated_at) {
|
|
return $this->updated_at->diffForHumans();
|
|
} else {
|
|
return Constant::NULL;
|
|
}
|
|
}
|
|
}
|