laravel-generator icon indicating copy to clipboard operation
laravel-generator copied to clipboard

[Enhancement]: Better definition for the route used for links.

Open phillipmadsen opened this issue 8 years ago • 2 comments

Many ways to do this but as of right now the routes are only working some of the time.

Here is an example using model binding into route:

/****************   Model binding into route **************************/
Route::model('call', 'App\Models\Call');
Route::model('category', 'App\Models\Category');
Route::model('city', 'App\Models\City');
Route::model('company', 'App\Models\Company');
Route::model('email', 'App\Models\Email'); 

Route::pattern('slug', '[a-z0-9-]+');
Route::pattern('slug2', '[a-z_]+');
Route::pattern('id', '[0-9]+');

Add this right into the routes file or a seperate file and include it like you did with api_routes.php

/* |--------------------------------------------------------------------------

route model binding
*/

require config('infyom.laravel_generator.path.route_model_binding_file');

phillipmadsen avatar Apr 11 '16 19:04 phillipmadsen

Like that above shown, also following style:

/posts /posts/comments

    /*
    * ----------------- Post Routes --------------
    */
    Route::resource("posts", "PostController");
    Route::group(['prefix' => 'posts'], function ()
    {
        /*
        * ----------------- Comment Routes --------------
        */
        Route::resource("comments", "CommentController");
        Route::group(['prefix' => 'comments'], function ()
        {        

NightZpy avatar Apr 21 '16 15:04 NightZpy

moving to the second milestone. Because we are going to implement some Exception handler stuff rather than just throwing 404 errors. #130

mitulgolakiya avatar May 07 '16 07:05 mitulgolakiya