Files
ERP-upgrade/app/Models/NetworkOperator.php
2026-08-17 19:37:22 +00:00

41 lines
1.1 KiB
PHP
Executable File

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Casts\Attribute;
class NetworkOperator extends Model
{
protected $guarded = array('id');
public $table = "network_operators";
protected $casts = [
'services' => 'array',
'support_emails' => 'array',
'finance_emails' => 'array',
'bind_specifics' => 'array',
];
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 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)
);
}
}