clrghouz/app/Models/Domain.php

42 lines
730 B
PHP
Raw Normal View History

2021-05-13 12:40:21 +00:00
<?php
namespace App\Models;
2021-06-15 12:19:14 +00:00
use Illuminate\Database\Eloquent\Factories\HasFactory;
2021-05-13 12:40:21 +00:00
use Illuminate\Database\Eloquent\Model;
use App\Traits\ScopeActive;
class Domain extends Model
{
2021-06-15 12:19:14 +00:00
use HasFactory,ScopeActive;
2021-06-14 11:33:18 +00:00
/* SCOPES */
/**
* Only query active records
*/
public function scopePublic($query)
{
return $query->where('public',TRUE);
}
/* RELATIONS */
public function zones()
{
return $this->hasMany(Zone::class);
}
2021-06-14 11:33:18 +00:00
/* 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));
}
2021-05-13 12:40:21 +00:00
}