Ejemplo n.º 1
0
        if ($this->currency_id) {
            return $this->currency_id;
        }
        if (!$this->account) {
            $this->load('account');
        }
        return $this->account->currency_id ?: DEFAULT_CURRENCY;
    }
    public function getTotalExpense()
    {
        return DB::table('expenses')->where('vendor_id', '=', $this->id)->whereNull('deleted_at')->sum('amount');
    }
}
Vendor::creating(function ($vendor) {
    $vendor->setNullValues();
});
Vendor::created(function ($vendor) {
    event(new VendorWasCreated($vendor));
});
Vendor::updating(function ($vendor) {
    $vendor->setNullValues();
});
Vendor::updated(function ($vendor) {
    event(new VendorWasUpdated($vendor));
});
Vendor::deleting(function ($vendor) {
    $vendor->setNullValues();
});
Vendor::deleted(function ($vendor) {
    event(new VendorWasDeleted($vendor));
});