Company.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace App\Models;
  3. use EloquentFilter\Filterable;
  4. use Illuminate\Database\Eloquent\Casts\Attribute;
  5. use Illuminate\Database\Eloquent\Factories\HasFactory;
  6. use Illuminate\Database\Eloquent\Model;
  7. use Illuminate\Database\Eloquent\SoftDeletes;
  8. class Company extends Model
  9. {
  10. use HasFactory,Filterable,SoftDeletes;
  11. protected $table = 'company';
  12. protected $fillable = [
  13. 'name',
  14. 'email',
  15. 'review_status',
  16. 'exp_date',
  17. 'parent_id',
  18. ];
  19. protected $guarded = [
  20. 'id'
  21. ];
  22. protected function storageSize(): Attribute
  23. {
  24. return Attribute::get(
  25. fn() => $this->storage_limit_size > 0
  26. ? $this->storage_limit_size
  27. : config("autocde.company_default_storage_limit_size") * 1024 * 1024
  28. );
  29. }
  30. public function parent(){
  31. return $this->belongsTo(Company::class ,'parent_id');
  32. }
  33. public function parentCompany(){
  34. return $this->belongsTo(Company::class ,'parent_id');
  35. }
  36. }