<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class SparepartLuar extends Model
{
protected $fillable = [
'service_id',
'nama_SL',
'jumlah_SL',
'diskon_SL',
'harga_modal_SL',
'harga_jual_SL'
];
use HasFactory;
// relasi ke table service
public function service()
{
return $this->belongsTo(Service::class, 'service_id', 'id');
}
public function getHargaDiskonAttribute()
{
$total = 0;
$total += $this->harga_jual_SL - $this->diskon_SL;
return $total;
}
public function getTotalSparepartAttribute()
{
$total = 0;
$total += (($this->harga_diskon)) * $this->jumlah_SL;
return $total;
}
public function getModalSparepartAttribute()
{
$total = 0;
$total += $this->harga_modal_SL * $this->jumlah_SL;
return $total;
}
}
Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]