"integer", // or "string" depending on your needs "group" => "string", // or "integer" if it's a numeric group ID "product_id" => "integer", // or "string" "profit_buy" => "float", // or "decimal:2" for monetary values "profit_sell" => "float", // or "decimal:2" "credit_buy" => "integer", // assuming these are true/false flags "credit_sell" => "integer", "auto_buy" => "boolean", "auto_sell" => "boolean", "is_active" => "boolean", ]; public function customer() { return $this->hasOne(Customer::class,'id','customer_id'); } public function product() { return $this->belongsTo(Product::class); } public function agent() { return $this->hasOne(Customer::class,'id','agent_id'); } public function getTitleAttribute() { if (array_key_exists('title', $this->attributes) && !is_null($this->attributes['title'])) { return $this->attributes['title']; } $t = "نامشخص"; if (is_null($this->customer_id) && is_null($this->group) && is_null($this->product_id)) { $t = "تنظیمات اصلی برای همه کاربران"; } if (!is_null($this->group)) { $t = "تنظیمات برای گروه " . $this->group; } if (!is_null($this->customer_id)) { $t = "تنظیمات برای " . ($this->customer->name ?? 'نامشخص'); } return $t; } }