Files
Global-Jain/app/Models/Notifications.php
2025-11-05 10:37:10 +05:30

56 lines
1.1 KiB
PHP

<?php
namespace App\Models;
use App\Models\Sant;
use App\Models\User;
use App\Models\Sangh;
use Illuminate\Database\Eloquent\Model;
class Notifications extends Model
{
protected $table = 'notifications';
protected $casts = [
'extra_fields' => 'array',
];
public function getCreatedAtAttribute()
{
if(isset($this->attributes['created_at'])) {
return str_replace('-', '/', $this->attributes['created_at']);
}
}
/**
* @return mixed
*/
public function user()
{
return $this->belongsTo(User::class, 'extra_fields->user_id');
}
/**
* @return mixed
*/
public function sant()
{
return $this->belongsTo(Sant::class, 'extra_fields->from_id');
}
/**
* @return mixed
*/
public function sangh()
{
return $this->belongsTo(Sangh::class, 'extra_fields->sangh_id');
}
public function getAttribute($key)
{
[$key, $path] = preg_split('/(->|\.)/', $key, 2) + [null, null];
return data_get(parent::getAttribute($key), $path);
}
}