Passing and printing a value of string from controller to views in laravel -


this simple question.but stuck. controller function tryng pass sum of columns in views printed @ end of table

public function totalbillc3()     {       $total = collection::where('collector_id', '=', 3)->sum('package');        return view::make('users.collector3', compact('total',$total));        } 

and in views have written

             <tr>                <td colspan="4" class="noborders"></td>                <th class="text-right" scope="row">total</th>                <td class="text-right">{{ $total}}</td>             </tr> 

i have route setup error showing

undefined variable: total (view: /volumes/g/zipbillingsoft.com/resources/views/users/collector3.blade.php).    please help. 

compact() takes 1 or more strings arguments, looks variables named strings.

in other words, should not do

compact('total', $total) 

but rather just

compact('total') 

and if have multiple variables, do

compact('total', 'something', 'something_else') 

documentation: http://php.net/compact


Comments