本文介绍了如何在Laravel Voyager中创建自定义控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在航海家很新.

在安装Voyager时,我已经将所有控制器放在TCG\\Voyager\\Http\\Controllers内部,但是没有找到我使用BREAD创建的其他控制器.

I have got all the controllers inside TCG\\Voyager\\Http\\Controllers while installing Voyager but didn't find other controllers those I have created using BREAD.

此外,我想在App\\Http\\Controllers\\Voyager内的Voyager管理面板中创建自定义控制器.我还按照YouTube中Voyager教程的步骤制作了自定义控制器,但无法创建.

Besides that I want to create custom controller in my Voyager admin panel inside App\\Http\\Controllers\\Voyager . I also followed the steps of Voyager tutorial in Youtube for making custom controller, but couldn't create.

有人帮忙吗?

推荐答案

在您的config \ voyager.php文件中,添加您的命名空间:

In your config\voyager.php file add your namespace:

'controllers' => [
    'namespace' => 'App\Http\Controllers\Back',
],

然后将voyageres控制器发布到您的名称空间

Then publish voyageres controllers to your namespace

php artisan voyager:controllers

在该命名空间内创建一个从VoyagerBreadController派生的新控制器

Within that namespace create a new controller derived from VoyagerBreadController

namespace App\Http\Controllers\Back;

use Illuminate\Http\Request;

class SchoolController extends VoyagerBreadController
{

然后,您可以在面包编辑器中指定控制器.

Then you can specify the controller in the bread editor.

注意:我确实不得不将我的名称称为Back \ SchoolController,而不是我所期望的仅仅是SchoolController.

NOTE: I did have to refer to mine as Back\SchoolController instead of just SchoolController as I would have expected.

这篇关于如何在Laravel Voyager中创建自定义控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 23:37