- add FK on arcadia_links to media.id and remove orphans - Refactored ArcadiaLinkController - Added comments on ArcadiaLink model - refactored arcadialinks.index
51 lines
1.1 KiB
PHP
51 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Carbon\Carbon;
|
|
|
|
/**
|
|
* @property integer $arcadia_id The ID on Arcadia side, Defaults to 0 (not linked).
|
|
* @property string $filename
|
|
*
|
|
* @property-read \App\Models\Media $media Media BelongsTo relationship.
|
|
* @package App\Models
|
|
*/
|
|
class ArcadiaLink extends Model
|
|
{
|
|
// * GETTERS
|
|
|
|
/**
|
|
* Get dateF attribute
|
|
*
|
|
* @return string
|
|
* @phpcs:disable Generic.NamingConventions.CamelCapsFunctionName.ScopeNotCamelCaps
|
|
*/
|
|
public function getDateFAttribute()
|
|
{
|
|
return Carbon::createFromFormat('Y-m-d H:i:s', $this->created_at)->format('d/m/Y H:i:s');
|
|
}
|
|
|
|
/**
|
|
* Get mediaUuid attribute
|
|
*
|
|
* @return string|null
|
|
*/
|
|
public function getMediaUuidAttribute()
|
|
{
|
|
return optional(Media::withTrashed()->find($this->media_id))->uid;
|
|
}
|
|
|
|
// * RELATIONSHIPS
|
|
|
|
/**
|
|
* BelongsTo media relation
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
*/
|
|
public function media()
|
|
{
|
|
return $this->belongsTo(Media::class);
|
|
}
|
|
}
|