Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overriding views not load #33

Closed
dukenst2006 opened this issue Apr 5, 2021 · 8 comments
Closed

Overriding views not load #33

dukenst2006 opened this issue Apr 5, 2021 · 8 comments

Comments

@dukenst2006
Copy link

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
Copy link
Owner

sebastienheyd commented Apr 6, 2021

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
Copy link
Author

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
Copy link
Owner

sebastienheyd commented Apr 6, 2021

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
Copy link
Owner

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

@dukenst2006
Copy link
Author

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

@dukenst2006
Copy link
Author

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 ?

@dukenst2006 dukenst2006 reopened this Apr 22, 2021
@sebastienheyd
Copy link
Owner

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

@sebastienheyd
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants