控制器返回空白数据

控制器返回空白数据/视图,我认为我的路线有问题。如果我删除{locale},则检索数据。


当我的路线中有数据时,任何人都可以帮助正确返回数据{locale}吗?这是我的相关代码:


网页.php


Route::get('{locale}/projects/{id}/billings', 'ProjectController@showbilling')

     ->name('showbilling');

Route::post('{locale}/projects/{id}', 'ProjectController@addbilling')

     ->name('addbilling');

项目控制器.php


public function showbilling($id)

{

    $billings = Project::find($id);

    $locale = app()->getLocale();


    return $billings;

    //return view('admin.addbillings', compact('billings'));

}

编辑:这是我的完整 web.php


网页.php


Route::get('/', function() {

    return redirect(app()->getLocale());

});




Route::group(['prefix' => '{locale}', 'where' => ['locale' => '[a-zA-Z]{2}'], 'middleware' => 'setlocale'], function () {


    Route::get('/', function () {


    return view('welcome');

    })->name('main');


    Auth::routes();


    Route::get('/home', 'HomeController@index')->name('home');


    //Customers

    Route::get('/customers', 'CustomerController@showcust')->name('customers');

    Route::post('/sendcust', 'CustomerController@sendcust')->name('sendcust');



    //Items

    Route::get('/items', 'ItemController@showitems')->name('items');

    Route::post('/senditem', 'ItemController@senditem')->name('senditem');


    //Projects

    Route::get('/projects', 'ProjectController@showprojects')->name('projects');

    Route::post('/sendproj', 'ProjectController@sendproj')->name('sendproj');

    //ProjectBillings

    Route::get('/projects/{id}/billings', 'ProjectController@showbilling')->name('showbilling');

    Route::post('/projects/{id}', 'ProjectController@addbilling')->name('addbilling');  

});


RISEBY
浏览 169回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP