Domanda

I have three urls:

localhost:8000/oc/online-marketing/ppc
localhost:8000/websystems/online-marketing/ppc
localhost:8000/all/online-marketing/ppc

and I need dynamic settings for each URL.

Before that, I've used to have the route.php like this:

Route::get('oc/online-marketing/ppc', function()
{
    $users = User::where('client_id', 1)->get();
    return View::make('users')->with('users', $users);
});

But I must set dynamic url like this: Route::get('{project}/{module}/{submodule}', ... ); where project is oc or websystems or all

The module is online-marketing

The submodule is ppc

The project name oc, websystems or all could be in table named users

How can I achieve that by using controllers?

È stato utile?

Soluzione

You may try something like foillowing, declare the Route like this:

Route::get('{project}/{module}/{submodule}', array('as' => 'mycontroller.project', 'uses' => 'MyController@project'));

Create the Controller:

class MyController extends BaseController {
    public function project($project, $module, $submodule)
    {
        //...
    }
}

Altri suggerimenti

Here's something to get you started with ...

In your routes.php file, you can have something like:

Route::get('/{clientID}', array('uses' => 'SomeController@someFunction'));

And in the SomeController.php file:

public function someFunction($clientID)
{
            $users = User::where('client_id', $clientID)->get();
            return View::make('users')->with('users', $users);
}

For more information, refer to http://laravel.com/docs/routing#route-parameters

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top