<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use DB;

class FoodController extends Controller
{
    public function store(Request $request)
    {
        $setting = DB::table('food_settings')->first();

        $price = $setting ? $setting->price : 0;

        $count = $request->count;

        $total = $count * $price;

        DB::table('food_amounts')->insert([
            'employee_id' => $request->employee_id,
            'count' => $count,
            'amount' => $total,
            'date' => $request->date
        ]);

        return back()->with('success','Food added successfully');
    }
}
