<?php

namespace App\Models;

use EloquentFilter\Filterable;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Company extends Model
{
    use HasFactory,Filterable,SoftDeletes;

    protected $table = 'company';

    protected $fillable = [
        'name',
        'email',
        'review_status',
        'exp_date',
        'parent_id',
    ];

    protected $guarded = [
        'id'
    ];

    protected function storageSize(): Attribute
    {
        return Attribute::get(
            fn() => $this->storage_limit_size > 0
                ? $this->storage_limit_size
                : config("autocde.company_default_storage_limit_size")  * 1024 * 1024
        );
    }
    public function parent(){
        return $this->belongsTo(Company::class ,'parent_id');
    }

    public function parentCompany(){
        return $this->belongsTo(Company::class ,'parent_id');
    }
}