<?php

namespace App\Models\Core\App;

use Illuminate\Database\Eloquent\Model;

class ApplicationModule extends Model
{
    protected $connection = 'system';

    protected $table = 'application_modules';

    protected $guarded = ['id'];

    public $timestamps = false;

    public function application()
    {
        return $this->belongsTo(\App\Models\Core\App\Application::class);
    }

    public function permissions()
    {
        return $this->hasMany(\App\Models\Core\Auth\Permission::class);
    }

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

    public function scopeByApplication($query, $id)
    {
        return $query->where('application_id', $id);
    }

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