Change controller model template in Laravel

I would like to know if there is a way to change the base template for the controller and model in laravel5.4

. I mean when I run:

php artisan make:controller ControllerName --resource

      

it will generate this:

<?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 to whatever I want to change and to the model.

+3


source to share


1 answer


Unfortunately, there is no "correct" way to do this.



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

+2


source







All Articles