Ris
Ris

Reputation: 1912

how to put routing and pages together

I am pretty new to Laravel, I am so confused on how to start this. but basically I have a switch statement with different display mode cases and what I am trying to do is to connect routing with blade. How do I display $mycontent in blade based on cases like these ? Thanks

switch(MyPage::$some_display_mode) {

case 'normal':
 $mycontent //this is what I want to display in blade

case 'ajax':


case 'other'
}

I want to connect these cases normal,ajax ,other etc with with different MyPages that I have so that I can display my blade files something like this

<html>
@yield('content)
</html>


@section('content')
whatever comes from the pages
@endsection

Upvotes: 0

Views: 42

Answers (1)

James Fannon
James Fannon

Reputation: 271

You can use route groups and do something similar to this:

Route::group( [ 'prefix' => 'AJAX', 'namespace' => 'AJAX' ], function()   {

   Route::get( '/something', 'ajaxController@doSomething' );

}); 

There is multiple ways to group routes shown here:

laravel grouped routing

Then handle returning the view in the controller and the use template-inheritance as explaned here:

laravel template-inheritance

This way will allow you to group and keep your routes organized

Upvotes: 1

Related Questions