After initializing a fresh instance of Laravel (and making all the necessary configurations), install the preset using one of the provided methods:
Via composer
Cd to your Laravel app
Type in your terminal: composer require laravel/ui and php artisan ui vue --auth
Install this preset via composer require laravel-frontend-presets/material-dashboard. No need to register the service provider. Laravel 5.5 & up can auto detect the package.
Run php artisan ui material command to install the Argon preset. This will install all the necessary assets and also the custom auth views, it will also add the auth route in routes/web.php
(NOTE: If you run this command several times, be sure to clean up the duplicate Auth entries in routes/web.php)
In your terminal run composer dump-autoload
Run php artisan migrate --seed to create basic users table
By using the archive
In your application's root create a presets folder
Copy and paste material-dashboard-master folder in presets (created in step 2) and rename it to material
Open composer.json file
Add "LaravelFrontendPresets\\MaterialPreset\\": "presets/material/src" to autoload/psr-4 and to autoload-dev/psr-4
Add LaravelFrontendPresets\MaterialPreset\MaterialPresetServiceProvider::class to config/app.php file
Type in your terminal: composer require laravel/ui and php artisan ui vue --auth
In your terminal run composer dump-autoload
Run php artisan ui material command to install the Material preset. This will install all the necessary assets and also the custom auth views, it will also add the auth route in routes/web.php
(NOTE: If you run this command several times, be sure to clean up the duplicate Auth entries in routes/web.php)
Run php artisan migrate --seed to create basic users table
Usage
Register a user or login using [email protected] and secret and start testing the preset (make sure to run the migrations and seeders for these credentials to be available).
Besides the dashboard and the auth pages this preset also has an edit profile page. All the necessary files (controllers, requests, views) are installed out of the box and all the needed routes are added to routes/web.php. Keep in mind that all of the features can be viewed once you login using the credentials provided above or by registering your own user.
Dashboard
You can access the dashboard either by using the "Dashboard" link in the left sidebar or by adding /home in the url.
Profile edit
You have the option to edit the current logged in user's profile (change name, email and password). To access this page just click the "User profile" link in the left sidebar or by adding /profile in the url.
The App\Http\Controllers\ProfileController handles the update of the user information.
public function update(ProfileRequest $request)
{
auth()->user()->update($request->all());
return back()->withStatus(__('Profile successfully updated.'));
}
Also you shouldn't worry about entering wrong data in the inputs when editing the profile, validation rules were added to prevent this (see App\Http\Requests\ProfileRequest). If you try to change the password you will see that other validation rules were added in App\Http\Requests\PasswordRequest. Notice that in this file you have a custom validation rule that can be found in App\Rules\CurrentPasswordCheckRule.
public function rules()
{
return [
'old_password' => ['required', 'min:6', new CurrentPasswordCheckRule],
'password' => ['required', 'min:6', 'confirmed', 'different:old_password'],
'password_confirmation' => ['required', 'min:6'],
];
}
请发表评论