I solved it. I just returned the array of variables without using compact().
Jun 16, 2019
5
Level 1
compact(): undefined variable
Good day, guys! I am trying to return a view with some data passed to it in compact() but for some reason, compact() is saying undefined variable despite showing me the variable value! I am a passing a value via an anchor tag to a controller function that accepts the passed variable as an argument.
My anchor tag:
<a class="btn btn-primary" href="{{url('/invoice/'.$orders)}}" target="_blank" value="{{$orders}}">View</a>
Route:
Route::get('/invoice/{orders}', 'Company\InvoicesController@viewOrder');
Controller:
public function viewOrder($orders){
//get other stuff here
return view('company.invoice', compact(['order_totals'=>$order_totals,
'order_items'=>$order_items,
'orderNum'=> $orders,
'other_fee'=>$this->other_fee,
'gct'=>$this->gct,
'processing_fee'=>$this->processing_fee,
'bank_fee'=>$this->bank_fee,
'title'=>'Invoice']));
}
Error says: compact(): Undefined variable: 111-2 (the order passed in by anchor tag)
Please or to participate in this conversation.