sebastienheyd / boilerplate

Laravel AdminLTE 3 Boilerplate package with blade components, users, roles and permissions management
MIT License
219 stars 66 forks source link

Overriding views not load #33

Closed dukenst2006 closed 3 years ago

dukenst2006 commented 3 years ago

Hi @sebastienheyd, Thanks for this great package, I want to customize the views, i run this command : php artisan vendor:publish --tag=boilerplate-views to override. and views are on resources/views/vendor/boilerplate when i edit the views on this folder, changes are not show even i clear cache and view. any idea how to fix that ? Thanks in advance.

Best,

sebastienheyd commented 3 years ago

Hi,

Which view do you want to edit ? The overriding system is the Laravel's one, as you can see in the boilerplate service provider. It will use namespace to know which view is overridden, I have to check if I don't forget to use the namespace somewhere.

dukenst2006 commented 3 years ago

Thanks for your quick response, i changed the footer view, also i would like to change the users/* views to add new fields. The path on config/view.php is resource_path('views') What is the best way to edit and have full control on the views and controllers that comes with the package? Thanks,

sebastienheyd commented 3 years ago

For controllers, the easiest way is to override login routes by setting them in routes/web.php :

$override = [
    'prefix'     => config('boilerplate.app.prefix', ''),
    'domain'     => config('boilerplate.app.domain', ''),
    'middleware' => ['web', 'boilerplatelocale'],
    'as'         => 'boilerplate.',
    'namespace'  => 'App\Http\Controllers' // < this is the important line
];

Route::group($override, function () {
    Route::get('login', ['as' => 'login', 'uses' => 'Auth\LoginController@showLoginForm']);
    Route::post('login', ['as' => 'login.post', 'uses' => 'Auth\LoginController@login']);

    // Add here the routes you have to override from src/routes/boilerplate.php
});

Will use the methods from app/Http/Controllers instead of Boilerplate controllers. Views are already overridden by those in resource/views/vendor/boilerplate

Copy the file src/Controllers/Auth/LoginController.php to app/Http/Controllers/Auth/LoginController.php. Edit the file to set the new namespace to App\Http\Controllers\Auth and you can change the methods for your needs.

sebastienheyd commented 3 years ago

Don't forget to set your new User model with additional fields in config/boilerplate/auth.php and config/boilerplate/laratrust.php

dukenst2006 commented 3 years ago

Thank you @sebastienheyd, really appreciate your response, keep up the great work. Best,

dukenst2006 commented 3 years ago

Hi @sebastienheyd I did exactly the changes you suggested but after a user has been created i got this issue, TypeError Sebastienheyd\Boilerplate\Events\UserCreated::__construct(): Argument #1 ($user) must be of type Sebastienheyd\Boilerplate\Models\User, App\Models\User given, called in any idea ?

sebastienheyd commented 3 years ago

You have to extend \Sebastienheyd\Boilerplate\Models\User instead of App\Models\User in your model.

sebastienheyd commented 3 years ago

Have a look to the new boilerplate:scaffold artisan command : https://sebastienheyd.github.io/boilerplate/howto/scaffold