belongsToMany(Product::class, 'order_lines', 'order_id', 'product_id'); } //Relations public function lines() { return $this->hasMany(OrderLine::class); } public function status() { return $this->belongsTo('App\Models\OrdersStatus', 'status_id'); } public function customer() { return $this->belongsTo(Customers::class); } public function timeslot() { return $this->hasOne(Timeslot::class); } //Formattages public function getFormattedTotalTtcAttribute() { return $this->attributes['formattedTotalTtc'] = sprintf('%s €', number_format($this->attributes['total'], 2, ',', ' ')); } }