46 lines
776 B
PHP
46 lines
776 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Frame extends Model
|
|
{
|
|
public function cug()
|
|
{
|
|
return $this->belongsTo(CUG::class);
|
|
}
|
|
|
|
protected static function boot() {
|
|
parent::boot();
|
|
|
|
static::addGlobalScope('order', function (Builder $builder) {
|
|
$builder->orderBy('created_at','DESC');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Return the Page Number
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getPageAttribute()
|
|
{
|
|
return $this->frame.$this->index;
|
|
}
|
|
|
|
public function hasFlag(string $flag)
|
|
{
|
|
// @todo When flags is in the DB update this.
|
|
return isset($this->flags) ? in_array($flag,$this->flags,FALSE) : FALSE;
|
|
}
|
|
|
|
/**
|
|
* Frame Types
|
|
*/
|
|
public function type()
|
|
{
|
|
return $this->type ?: 'i';
|
|
}
|
|
} |