67 lines
1.3 KiB
PHP
67 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Illuminate\Support\Str;
|
|
|
|
class Tenant extends Model
|
|
{
|
|
use HasFactory, SoftDeletes;
|
|
|
|
protected $fillable = [
|
|
'name',
|
|
'slug',
|
|
'domain',
|
|
'is_active',
|
|
'default_locale',
|
|
'default_calendar',
|
|
'base_currency_id',
|
|
'allow_multi_currency',
|
|
'logo_path',
|
|
'settings',
|
|
];
|
|
|
|
protected $casts = [
|
|
'is_active' => 'boolean',
|
|
'allow_multi_currency' => 'boolean',
|
|
'settings' => 'array',
|
|
];
|
|
|
|
protected static function booted()
|
|
{
|
|
static::creating(function ($tenant) {
|
|
if (empty($tenant->slug)) {
|
|
$tenant->slug = Str::slug($tenant->name);
|
|
}
|
|
});
|
|
}
|
|
|
|
public function baseCurrency()
|
|
{
|
|
return $this->belongsTo(Currency::class, 'base_currency_id');
|
|
}
|
|
|
|
public function users()
|
|
{
|
|
return $this->hasMany(User::class);
|
|
}
|
|
|
|
public function projects()
|
|
{
|
|
return $this->hasMany(Project::class);
|
|
}
|
|
|
|
public function employees()
|
|
{
|
|
return $this->hasMany(Employee::class);
|
|
}
|
|
|
|
public function expenses()
|
|
{
|
|
return $this->hasMany(Expense::class);
|
|
}
|
|
}
|