I have passed value on variable from controller to view page, and show the value in foreach
loop. Now I want to do, when execute foreach
loop, any value I want to pass in "test" controller method.. I have a query defendant on this value.
A) Is there a way of getting the response of a controller from within a view
B) Is there a way of getting the response of a controller from within a controller method, so that I can push the result to the view? My code so far is:
First action on this method : (AccHeadController/create)
public function create()
{
$root = DB::table('chart_of_account')
->select('*')
->where('parent_id','=',0)
->get();
return view('pages.createacchead')->with('level1', $root);
}
And Pass level1 variable on view page (pages.createacchead) :
<fieldset>
@foreach($level1 as $item)
<ul>
<li>
<input type="radio" name="acchead" value="{{$item->id}}"> {{$item->title}}</br>
</li>
</ul>
@endforeach
</fieldset>
how to pass $item->id to AccHeadController test methode when execute foreach?
And here is AccHeadController/test method :
public function test($id){
$root = DB::table('chart_of_account')
->select('*')
->where('parent_id','=',$id)
->get();
}
Actually I want to show unlimited sub menu.