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
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 for anything I want to change the model as well.
There was no way in Laravel 5, but from laravel 7 you can customize the stubs
Execute this command to publish all available stubs for customization
php artisan stub:publish
When we publish stub then all files of stub will be located within a stubs directory in the root of your application.
You can now edit all .stub files and customize your project files
I also suggest you read this blog post:
https://arievisser.com/blog/how-to-use-stub-customization-in-laravel/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With