Reputation: 11
I am an beginner for Laravel, just to know what went wrong as after I saved my data from the form, it will redirect me to an index page, which was want from beginning then only I am able to view my quotation details. But right now what I need is that after adding new quotation, I need it to redirect me to the quotation details straight away.
return view('bd.quotation.index', compact('quotations'));
This is the part where I put it to redirect me to the quotations index.
redirect('/bd/quotation/{id}'); // type 1
function showQuotation($id) {
return view('bd.quotation.quotationItem', compact('customers','quotations','quotationItems','quotationIT' ));
}
Type 1 I tried, it's not working. It will show me a blank page and the second one isn't working as well.
public function quotationItem($id)
{
$quotations= Quotation::where('id', $id)->first();
$customers = Customer::where('id', $quotations->cust_id)->first();
$quotationIT = QuotationIT::where('quotation_number', $quotations->item_name)->first();
$quotationItems = QuotationItem::where('quotation_number', $id)->get();
return view('bd.quotation.quotationItem', compact('customers','quotations','quotationItems','quotationIT' ));
}
This is the code where I able to see my quotation details.
Upvotes: 1
Views: 1684
Reputation: 38
Try this to redirect with id, I think this way will help you
return redirect()->route('a_newsEvents',['id'=>$id]);
Upvotes: 0
Reputation: 636
i think your problem is that you didnt return redirect
so change: redirect('/bd/quotation/{id}');
to return redirect('/bd/quotation/{id}');
there are 3 steps to redirect:
1- is to return redirect function in controller after saving your data:
return redirect('your-url');
2-make route for that in web.php:
Route::get('your-url', 'YourController@yourFunction');
3-writing yourFunction:
public function yourFunction()
{
return "you are here";
}
Upvotes: 1