mardi 22 décembre 2020

Laravel | Generate automatically invoice with laravel

i am working on 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 dont 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 with easiest way? Thanks in advance. And sorry about my bad english too




Aucun commentaire:

Enregistrer un commentaire