2022-10-22 14:18:21 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
class SyndicationTarget extends Model
|
|
|
|
{
|
|
|
|
use HasFactory;
|
|
|
|
|
2022-10-23 13:11:31 +01:00
|
|
|
/**
|
|
|
|
* The attributes that are mass assignable.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $fillable = [
|
|
|
|
'uid',
|
|
|
|
'name',
|
|
|
|
'service_name',
|
|
|
|
'service_url',
|
|
|
|
'service_photo',
|
|
|
|
'user_name',
|
|
|
|
'user_url',
|
|
|
|
'user_photo',
|
|
|
|
];
|
|
|
|
|
2022-10-22 14:18:21 +01:00
|
|
|
/**
|
|
|
|
* The attributes that are visible when serializing the model.
|
|
|
|
*
|
|
|
|
* @var array<string>
|
|
|
|
*/
|
|
|
|
protected $visible = [
|
|
|
|
'uid',
|
|
|
|
'name',
|
|
|
|
'service',
|
|
|
|
'user',
|
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The accessors to append to the model's array form.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $appends = [
|
|
|
|
'service',
|
|
|
|
'user',
|
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the service data as a single attribute.
|
|
|
|
*
|
|
|
|
* @vreturn Attribute
|
|
|
|
*/
|
|
|
|
protected function service(): Attribute
|
|
|
|
{
|
|
|
|
return Attribute::get(
|
|
|
|
get: fn ($value, $attributes) => [
|
|
|
|
'name' => $attributes['service_name'],
|
|
|
|
'url' => $attributes['service_url'],
|
|
|
|
'photo' => $attributes['service_photo'],
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the user data as a single attribute.
|
|
|
|
*
|
|
|
|
* @vreturn Attribute
|
|
|
|
*/
|
|
|
|
protected function user(): Attribute
|
|
|
|
{
|
|
|
|
return Attribute::get(
|
|
|
|
get: fn ($value, $attributes) => [
|
|
|
|
'name' => $attributes['user_name'],
|
|
|
|
'url' => $attributes['user_url'],
|
|
|
|
'photo' => $attributes['user_photo'],
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|