api code global jain
This commit is contained in:
55
app/Models/Notifications.php
Normal file
55
app/Models/Notifications.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user