mardi 16 juillet 2019

How to fix BREAD route to work in frontend

I created table Document but I want the users to use not just admin.

In voyager routes I copied BREAD part and tried to modify it to work for frontend with no success

<?php
Route::prefix('user')->group(

    function() {

        $namespacePrefix = '\\'.config('voyager.controllers.namespace').'\\';

        $breadController = $namespacePrefix.'VoyagerBaseController';

        foreach (Voyager::model('DataType')::all() as $dataType) 
        {
            $breadController = $dataType->controller 
                ? Str::start($dataType->controller, '\\') 
                : $namespacePrefix.'VoyagerBaseController';

            if( Auth::user()->can('browse', app($dataType->model_name)) )
            {
                Route::get($dataType->slug.'/order', $breadController.'@order')->name($dataType->slug.'.order');
                Route::post($dataType->slug.'/action', $breadController.'@action')->name($dataType->slug.'.action');
                Route::post($dataType->slug.'/order', $breadController.'@update_order')->name($dataType->slug.'.order');
                Route::get($dataType->slug.'/{id}/restore', $breadController.'@restore')->name($dataType->slug.'.restore');
                Route::get($dataType->slug.'/relation', $breadController.'@relation')->name($dataType->slug.'.relation');
                Route::resource($dataType->slug, $breadController);
            }
        }
});

?>

Route "user/{slug}" as tcg\vouager\src\Http\Controller\Controller.php getSlug function returning slug as "index".

I want mydomain.com/user/document will show document table BREAD/CRUD. Thanks!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire