jeroennoten / Laravel-AdminLTE

Easy AdminLTE integration with Laravel
MIT License
3.78k stars 1.08k forks source link

How to customize "Register" and "Login" Views and Controllers? #1263

Closed chegmarco1989 closed 3 months ago

chegmarco1989 commented 3 months ago

Hello.

I added "phone" and "country" columns to "users" Migrations. But I didn't find in "Auth/RegisterController" and "resources/views/Auth/Register.blade.php" where to handle (add) these news fields in Controller and Views.

1. So, How to add them ("phone" and "country") in Controller and Views for registering ???

2. How to add My Custum CSS and JS files in Register.blade.php and Login.blade.php because I want to add my own files in their Header ???

Thanks to answer me. Awaiting.

dfsmania commented 3 months ago

Hi @chegmarco1989 , to customize the package views, you need to publish them first. Once published, you can change the registering form at: resources/views/vendor/adminlte/auth/register.blade.php.

Changing the controller logic will depend on the authentication scaffolding you're using, it's external to this package. Assuming that you're using the legacy laravel/ui, you should look at file app/Http/Controllers/Auth/RegisterController.php.

To add custom CSS and JS to the login form, for example, you need to configure a plugin entry for your files. Example:

'plugins' => [
    ...
    'MyCompanyFiles' => [
        'active' => false,
        'files' => [
            [
                'type' => 'js',
                'asset' => true,
                'location' => 'vendor/my-company-files/js/file.js',
            ],
            [
                'type' => 'css',
                'asset' => true,
                'location' => 'vendor/my-company-files/css/file.css',
            ],
        ],
    ],
    ...
],

Then, enable this plugin entry in the published login form by adding the next line after @extends('adminlte::auth.auth-page', ['auth_type' => 'login']):

@section('plugins.MyCompanyFiles', true)
chegmarco1989 commented 3 months ago

Ok Thanks for your answer