Files
numstation-web/app/Models/Company.php
2023-12-22 12:35:55 +08:00

48 lines
1.0 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Company extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'email',
'name_english',
'name_chinese',
'registered_office_address_english',
'registered_office_address_chinese',
'br_number',
'xero_api_key',
];
public function getNameAttribute()
{
if (strtolower(app()->getLocale()) == 'zh_hk') {
return $this->name_chinese;
}
return $this->name_english;
}
public function getRegisteredOfficeAddressAttribute()
{
if (strtolower(app()->getLocale()) == 'zh_hk') {
return $this->registered_office_address_chinese;
}
return $this->registered_office_address_english;
}
public function users()
{
return $this->hasMany(User::class);
}
}