<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\hasMany;
use Illuminate\Database\Eloquent\Relations\hasOne;

class Company extends Model {
    use HasFactory;

    public $table = 'companies';
    public $primaryKey = 'id';

    protected $fillable = [
        'name'
    ];

    public function users(): hasMany {
        return $this->hasMany(User::class);
    }

    public function cabinClasses(): hasMany
    {
        return $this->hasMany(CabinClass::class);
    }

    public function folder(): hasMany {
        return $this->hasMany(Folder::class);
    }

    public function delete()
    {
        $this->cabinClasses()->delete();
        return parent::delete();
    }
}
