<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Menu extends Model
{
    protected $fillable = ['title','toko_id','amount','price'];//

    public function tokos()
    {
      return  $this->belongsTo('App\Toko');
    }

    public function beliLogs()
    {
    return $this->hasMany('App\BeliLog');
    }
    public function getStockAttribute()
    {
    $beli = $this->beliLogs()->beli()->count();
    $stock = $this->amount - $beli;
    return $stock;
    }

}
