在Laravel中更改控制器模型模板 [英] Change controller model template in Laravel

查看:122
本文介绍了在Laravel中更改控制器模型模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有任何方法可以更改laravel5.4中控制器和模型的基本模板.我的意思是,当我跑步时:

I'd like to know if there is any way to change the basic template for the controller and the model in laravel5.4. I mean when I run:

php artisan make:controller ControllerName --resource

它将生成以下内容:

<?php
 namespace App\Http\Controllers;
 use Illuminate\Http\Request;
 class UsersController extends Controller
{
public function index()
{
    return view('users.index');
}
public function create()
{

}
public function store(Request $request)
{

}
public function show($id)
{

}
public function edit($id)
{

}
public function update(Request $request, $id)
{

}
public function destroy($id)
{

}
}

我还需要为要更改模型的任何内容更改此模板.

I need to change this template for anything I want to change the model as well.

推荐答案

不幸的是,没有任何适当"的方法可以做到这一点.

Unfortunately, there isn't any "proper" way to do this.

如注释中所述,最好的解决方案是创建自己的Command,该Command将为您创建必要的文件.您可以在此处找到用于编写自定义命令的文档: https://laravel.com/docs/master/artisan#writing-commands

The best solution, as mentioned in the comments, would be to create your own Command which would create the necessary file for you. You can find documentation for writing custom commands here: https://laravel.com/docs/master/artisan#writing-commands

这篇关于在Laravel中更改控制器模型模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆