InfyOmLabs / laravel-generator

API and Admin Panel CRUD Generator for Laravel.
https://www.infyom.com/open-source
MIT License
3.79k stars 813 forks source link

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

Open phillipmadsen opened 8 years ago

phillipmadsen commented 8 years ago

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');

NightZpy commented 8 years ago

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 ()
        {        
mitulgolakiya commented 8 years ago

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