I am working on a very simple project for my school assignment. So it's a house rent site. Everything seems fine but I want create an automatically invoice like "INV0001" but I don't know how to do that. Maybe you guys can help me fix my controller
This is my controller
public function storeSewa(Request $request){
if ($request->edit=='false') {
$newdata = new Sewa;
} else {
$newdata = Sewa::find($request->id);
if ($newdata) {
//
}else {
$newdata = new Sewa;}}
$newdata->invoice = 'INV/'//idk, how?
$newdata->penyewa_id = $request->penyewa_id;
$newdata->kamar_id = $request->kamar_id;
$newdata->tanggal_masuk = $request->tanggal_masuk;
$newdata->tanggal_keluar = $request->tanggal_keluar;
$newdata->durasi = $request->durasi;
$newdata->status = 'Belum Lunas';
$newdata->save();
if ($newdata) {
session()->flash('status', 'Task was successful!');
session()->flash('type', 'success');
return Redirect::route('account');
}
return 'false';
}
Well, I am very new to laravel, so is there anyone can help fix my problem in the easiest way?