Anons79 Mini Shell

Directory : /home/aplikasiposinfo/public_html/hayyumart.com/app/
Upload File :
Current File : /home/aplikasiposinfo/public_html/hayyumart.com/app/ReturPenjualan.php

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class ReturPenjualan extends Model
{
    use SoftDeletes;
    protected $guarded = [];
    protected $primaryKey = "no_retur_penjualan";
    public $incrementing = false;

    public function penjualan()
    {
    	return $this->belongsTo(Penjualan::class,'kd_penjualan')->withTrashed();
    }

    public function user()
    {
        return $this->belongsTo(User::class,'id_user')->withTrashed();
    }

    public function detail()
    {
    	return $this->hasMany(DetailReturPenjualan::class,'no_retur_penjualan');
    }

    public function getJumlahAttribute()
    {
        $jumlah = 0;
        foreach ($this->detail as $e) {
            $jumlah += $e->jumlah;
        }
        return $jumlah;
    }

    public function delete(){
        $this->detail()->delete();
        parent::delete();
    }
}

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]