<?php
namespace App\Models\Core\App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Application extends Model
{
    protected $connection = 'system';
    protected $guarded = ['id'];
    public $timestamps = false;

    public function pages()
    {
        return $this->hasMany(\App\Models\Core\App\ApplicationPage::class);
    }

    public function modules()
    {
        return $this->hasMany(\App\Models\Core\App\ApplicationModule::class);
    }

    public function scopeActive($query)
    {
        return $query->where('active', 1);
    }

    public function scopeVisible($query)
    {
        return $query->where('visible', 1);
    }

    public function scopeBySlug($query, $slug)
    {
        return $query->where('slug', $slug);
    }

    public function scopeByOrder($query)
    {
        return $query->sortBy('order');
    }
}
