42 lines
730 B
PHP
42 lines
730 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
use App\Traits\ScopeActive;
|
|
|
|
class Domain extends Model
|
|
{
|
|
use HasFactory,ScopeActive;
|
|
|
|
/* SCOPES */
|
|
|
|
/**
|
|
* Only query active records
|
|
*/
|
|
public function scopePublic($query)
|
|
{
|
|
return $query->where('public',TRUE);
|
|
}
|
|
|
|
/* RELATIONS */
|
|
|
|
public function zones()
|
|
{
|
|
return $this->hasMany(Zone::class);
|
|
}
|
|
|
|
/* CASTS */
|
|
|
|
public function getHomePageAttribute($value)
|
|
{
|
|
return $value ? gzuncompress(base64_decode($value)) : 'No available information at the moment.';
|
|
}
|
|
|
|
public function setHomePageAttribute($value)
|
|
{
|
|
$this->attributes['homepage'] = base64_encode(gzcompress($value,9));
|
|
}
|
|
} |