40 lines
1010 B
PHP
40 lines
1010 B
PHP
<?php
|
|
|
|
namespace Modules\Notice\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Notice extends Model
|
|
{
|
|
protected $table = 'notices';
|
|
|
|
protected $fillable = [
|
|
'user_id',
|
|
'action',
|
|
'object_name',
|
|
'object_id',
|
|
'read_at'
|
|
];
|
|
|
|
public function toString()
|
|
{
|
|
$noticeName = "$this->action $this->object_name";
|
|
$noticeClass = __DIR__ . '/' . config('notice.types.' . $noticeName);
|
|
if (file_exists($noticeClass . '.php')) {
|
|
$noticeClass = 'Modules\\Notice\\Models\\' . config('notice.types.' . $noticeName);
|
|
if ($parameters = $noticeClass::getParameters($this)) {
|
|
return __("notification.$this->action $this->object_name", $parameters);
|
|
};
|
|
};
|
|
return FALSE;
|
|
//
|
|
}
|
|
|
|
public function created_at()
|
|
{
|
|
return date_format(date_create($this->created_at), env('DATETIME_FORMAT'));
|
|
}
|
|
|
|
}
|