Anons79 Mini Shell

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

<?php

namespace App;

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

class Realisasi extends Model
{
    use SoftDeletes;
    protected $guarded = [];

    public function pembelian()
    {
        return $this->belongsTo(Pembelian::class,'no_pembelian')->withTrashed();
    }

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

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

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

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

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

    public function detail()
    {
    	return $this->hasMany(DetailRealisasi::class)->withTrashed();
    }

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

    public function getStatusAttribute()
    {
        $status = 'Proses Input';
        if ($this->prepared_id) {
            $status = 'Prepared';
            if ($this->reviewed_id) {
                $status = 'Reviewed';
                if ($this->approved_id) {
                    $status = 'Approved';
                    if ($this->received_id) {
                        $status = 'Received';
                    }
                }
            }
        }
        
        if ($this->rejected_id) {
            $status = 'Rejected';
        }
        return $status;
    }

    public function getNextStatusAttribute()
    {
        $nextStatus = 'Proses Input';
        
        if ($this->prepared_id) {
            $nextStatus = 'Reviewed';
            if ($this->reviewed_id) {
                $nextStatus = 'Approved';
                if ($this->approved_id) {
                    $nextStatus = 'Received';
                }
            }
        }

        return $nextStatus;
    }

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

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