Files
ERP-upgrade/app/Models/NetworkOperator.php
2026-10-13 14:29:40 +00:00

53 lines
1.5 KiB
PHP
Executable File

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Casts\Attribute;
use App\Traits\LogsActivity;
class NetworkOperator extends Model
{
use LogsActivity;
protected $guarded = array('id');
public $table = "network_operators";
protected $casts = [
'services' => 'array',
'support_emails' => 'array',
'finance_emails' => 'array',
'bind_specifics' => 'array',
'contract_auto_renew' => 'boolean',
'next_renewal_date' => 'date',
];
public function account_manager_info(){
return $this->hasOne('App\Models\StaffMember', 'id', 'account_manager_id');
}
public function connectionDetails()
{
return $this->hasMany(NetworkOperatorConnection::class, 'network_operator_id');
}
public function documents()
{
return $this->hasMany(NetworkOperatorDocument::class);
}
public function notes()
{
return $this->hasMany(\App\Models\Mnonote::class, 'mno_id', 'id')->latest();
}
/*
public function setBuyingRateAttribute($value)
{
$cleanValue = filter_var($value, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
$this->attributes['buying_rate'] = $cleanValue;
}
*/
protected function buyingRate(): Attribute
{
return Attribute::make(
set: fn (string $value) => filter_var($value, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION)
);
}
}