<?php
namespace App\Http\Controllers;
use App\Models\Currency; use App\Models\Supplier; use App\Models\SupplierPayment; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth;
class SupplierPaymentController extends Controller {
 public function create(){ return view('payments.supplier_create',['suppliers'=>Supplier::all(),'currencies'=>Currency::where('is_active',true)->get()]); }
 public function store(Request $request){ $data=$request->validate(['supplier_id'=>'required|exists:suppliers,id','currency_id'=>'required|exists:currencies,id','exchange_rate'=>'nullable|numeric','payment_date'=>'required|date','amount'=>'required|numeric|min:0','payment_method'=>'required','notes'=>'nullable']); $data['payment_no']='PAY-'.now()->format('YmdHis'); $data['user_id']=Auth::id(); SupplierPayment::create($data); return redirect()->route('suppliers.index')->with('success','Supplier payment saved.'); }
}
