<?php
namespace App\Http\Controllers;
use App\Models\Currency; use App\Models\Customer; use App\Models\CustomerReceipt; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth;
class ReceiptController extends Controller {
 public function create(){ return view('receipts.customer_create',['customers'=>Customer::where('is_active',true)->get(),'currencies'=>Currency::where('is_active',true)->get()]); }
 public function store(Request $request){ $data=$request->validate(['customer_id'=>'required|exists:customers,id','currency_id'=>'required|exists:currencies,id','exchange_rate'=>'nullable|numeric','receipt_date'=>'required|date','amount'=>'required|numeric|min:0','payment_method'=>'required','notes'=>'nullable']); $data['receipt_no']='REC-'.now()->format('YmdHis'); $data['user_id']=Auth::id(); CustomerReceipt::create($data); return redirect()->route('customers.index')->with('success','Customer receipt saved.'); }
}
