vendredi 6 avril 2018

How to call multiple methods or controllers to a same route in laravel

Find below the controller code with two methods and suggest me how to call these two methods in the same route or whether I have to create two different controllers for the same page(route).

class TicketController extends Controller
{
    public function show(){
    $results=Whmcs::GetTickets([

    ]);
    return view('clientlayout.main.index',compact('results'));
}

    public function set(){
    $test=Whmcs::GetInvoices([

    ]);
    return view('clientlayout.main.index',compact('test'));
}

}

Find below the route file..

  Route::get('clientlayout.main.index','TicketController@show');

  Route::get('clientlayout.main.index','TicketController@set');

Find the code in the blade file and after running this I'm getting an error as undefined index:Results.

  @foreach($results['tickets']['ticket'] as $key)

  
  @endforeach



  @foreach($test['invoices']['invoice'] as $value)

  
  @endforeach

When I run these two foreach loops in a different blade file it executes correctly..But I need these two results to be viewed in the same file.. So suggest me a solution to view both tickets and invoices in the same index page...



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire