InterNACHI / modular

Modularize your Laravel application
MIT License
796 stars 65 forks source link

Customize stub with Module name placeholder #104

Open masiorama opened 1 month ago

masiorama commented 1 month ago

Hi there, I'm trying to customize stubs in order to create a controller which is kinda ready to work with inertia+vue.

The stub name is controller.inertia.stub, inside stubs directory in the root, and the content is something like this:

<?php

namespace {{ namespace }};

use {{ rootNamespace }}Http\Controllers\Controller;
use Inertia\Inertia;
use Inertia\Response;

class {{ class }} extends Controller
{
    /**
     * Display a listing of the resource.
     */
    public function index(): Response
    {
        return Inertia::render('[ModuleName]::index');
    }
}

The executed command to generate the controller is php artisan make:controller NameController -r --module=[module name] --type=inertia

I don't know if this isn't the right approach but:

I tried applying some variations of this but had no luck.

Thanks for any suggestion.