<?php

namespace App\Http\Controllers\Admin;

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

use DB;
use Illuminate\Support\Facades\Schema;  //special
use Carbon\Carbon;
use Auth;


class AdvanceController extends Controller
{
    // 🔹 Add Advance
        public function store(Request $request)
        {
            DB::table('advances')->insert([
                'employee_id' => $request->employee_id,
                'amount' => $request->amount,
                'date' => $request->date,
                'note' => $request->note,
                'status' => 'pending'
            ]);

            return back()->with('success','Advance Added');
        }

        // 🔹 Settle Advance
        public function settle($id)
        {
            DB::table('advances')
                ->where('id', $id)
                ->update([
                    'status' => 'settled'
                ]);

            return back()->with('success','Advance Settled');
        }
}
