clrghouz/app/Models/Domain.php

52 lines
886 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 */
2021-08-11 13:45:30 +00:00
public function echoareas()
{
return $this->hasMany(Echoarea::class);
}
public function fileareas()
{
return $this->hasMany(Filearea::class);
}
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
}