Skip to content

Commit e42d6be

Browse files
material dashbord free preset
0 parents  commit e42d6be

File tree

268 files changed

+59338
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

268 files changed

+59338
-0
lines changed

changelog.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Changelog
2+
3+
All notable changes to `Material Dashboard` frontend preset for Laravel will be documented in this file.
4+
5+
## Version 1.0.0
6+
7+
### Added
8+
- Material Dashboard v1.0.0 frontend theme
9+
- Laravel Auth preset
10+
- Change user profile
11+
- User CRUD

license.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 Creative Tim (https://www.creative-tim.com)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

readme.md

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
# Welcome to Material Dashboard FREE Laravel Live Preview
2+
3+
Speed up your web development with the Bootstrap 4 Admin Dashboard built for Laravel Framework 5.5 and up.
4+
5+
*Current version*: Material Dashboard v1.0.0. More info at https://www.creative-tim.com/product/material-dashboard-laravel.
6+
7+
## Note
8+
9+
We recommend installing this preset on a project that you are starting from scratch, otherwise your project's design might break.
10+
11+
## Prerequisites
12+
13+
If you don't already have an Apache local environment with PHP and MySQL, use one of the following links:
14+
15+
- Windows: http://tutorial.razi.net.my/search?q=uwamp
16+
- Linux: https://howtoubuntu.org/how-to-install-lamp-on-ubuntu
17+
- Mac: https://wpshout.com/quick-guides/how-to-install-mamp-on-your-mac/
18+
19+
Also, you will need to install Composer: https://getcomposer.org/doc/00-intro.md
20+
And Laravel: https://laravel.com/docs/5.8/installation
21+
22+
## Installation
23+
24+
After initializing a fresh instance of Laravel (and making all the necessary configurations), install the preset using one of the provided methods:
25+
26+
### Via composer
27+
28+
1. `Cd` to your Laravel app
29+
2. Install this preset via `composer require laravel-frontend-presets/material`. No need to register the service provider. Laravel 5.5 & up can auto detect the package.
30+
3. Run `php artisan preset 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`
31+
(NOTE: If you run this command several times, be sure to clean up the duplicate Auth entries in routes/web.php)
32+
4. In your terminal run `composer dump-autoload`
33+
5. Run `php artisan migrate --seed` to create basic users table
34+
35+
### By using the archive
36+
37+
1. In your application's root create a **presets** folder
38+
2. [Download an archive](https://github.com/laravel-frontend-presets/material-dashboard/archive/master.zip) of the repo and unzip it
39+
3. Copy and paste **material-dashboard-master** folder in presets (created in step 2) and rename it to **material**
40+
4. Open `composer.json` file
41+
5. Add `"LaravelFrontendPresets\\MaterialPreset\\": "presets/material/src"` to `autoload/psr-4` and to `autoload-dev/psr-4`
42+
6. Add `LaravelFrontendPresets\MaterialPreset\MaterialPresetServiceProvider::class` to `config/app.php` file
43+
7. In your terminal run `composer dump-autoload`
44+
8. Run `php artisan preset 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`
45+
(NOTE: If you run this command several times, be sure to clean up the duplicate Auth entries in routes/web.php)
46+
9. Run `php artisan migrate --seed` to create basic users table
47+
48+
49+
## Usage
50+
51+
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).
52+
53+
Besides the dashboard and the auth pages this preset also has a user management example and 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.
54+
55+
### Dashboard
56+
57+
You can access the dashboard either by using the "**Dashboard**" link in the left sidebar or by adding **/home** in the url.
58+
59+
### Profile edit
60+
61+
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.
62+
63+
The `App\Htttp\Controlers\ProfileController` handles the update of the user information.
64+
65+
```
66+
public function update(ProfileRequest $request)
67+
{
68+
auth()->user()->update($request->all());
69+
70+
return back()->withStatus(__('Profile successfully updated.'));
71+
}
72+
```
73+
74+
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`.
75+
76+
```
77+
public function rules()
78+
{
79+
return [
80+
'old_password' => ['required', 'min:6', new CurrentPasswordCheckRule],
81+
'password' => ['required', 'min:6', 'confirmed', 'different:old_password'],
82+
'password_confirmation' => ['required', 'min:6'],
83+
];
84+
}
85+
```
86+
87+
### User management
88+
89+
The preset comes with a user management option out of the box. To access this click the "**User Management**" link in the left sidebar or add **/user** to the url.
90+
The first thing you will see is the listing of the existing users. You can add new ones by clicking the "**Add user**" button (above the table on the right). On the Add user page you will see the form that allows you to do this. All pages are generate using blade templates:
91+
92+
```
93+
<div class="row">
94+
<label class="col-sm-2 col-form-label">{{ __('Name') }}</label>
95+
<div class="col-sm-7">
96+
<div class="form-group{{ $errors->has('name') ? ' has-danger' : '' }}">
97+
<input class="form-control{{ $errors->has('name') ? ' is-invalid' : '' }}" name="name" id="input-name" type="text" placeholder="{{ __('Name') }}" value="{{ old('name') }}" required="true" aria-required="true"/>
98+
@if ($errors->has('name'))
99+
<span id="name-error" class="error text-danger" for="input-name">{{ $errors->first('name') }}</span>
100+
@endif
101+
</div>
102+
</div>
103+
</div>
104+
```
105+
106+
Also validation rules were added so you will know exactely what to enter in the form fields (see `App\Http\Requests\UserRequest`). Note that these validation rules also apply for the user edit option.
107+
108+
```
109+
public function rules()
110+
{
111+
return [
112+
'name' => [
113+
'required', 'min:3'
114+
],
115+
'email' => [
116+
'required', 'email', Rule::unique((new User)->getTable())->ignore($this->route()->user->id ?? null)
117+
],
118+
'password' => [
119+
$this->route()->user ? 'nullable' : 'required', 'confirmed', 'min:6'
120+
]
121+
];
122+
}
123+
```
124+
125+
Once you add more users, the list will get bigger and for every user you will have edit and delete options (access these options by clicking the three dotted menu that appears at the end of every line).
126+
127+
All the sample code for the user management can be found in `App\Http\Controllers\UserController`. See store method example bellow:
128+
129+
```
130+
public function store(UserRequest $request, User $model)
131+
{
132+
$model->create($request->merge(['password' => Hash::make($request->get('password'))])->all());
133+
134+
return redirect()->route('user.index')->withStatus(__('User successfully created.'));
135+
}
136+
```
137+
138+
## Change log
139+
140+
Please see the [changelog](changelog.md) for more information on what has changed recently.
141+
142+
## Credits
143+
144+
- [Creative Tim](https://creative-tim.com/)
145+
- [Updivision](https://updivision.com)
146+
147+
## License
148+
149+
[MIT License](https://github.com/laravel-frontend-presets/material-dashboard/blob/master/license.md).
150+
151+
## Screen shots
152+
153+
![Material Login](/screens/Login.png)
154+
155+
![Material Dashboard](/screens/Dashboard.png)
156+
157+
![Material Users](/screens/Users.png)
158+
159+
![Material Profile](/screens/Profile.png)

screens/Dashboard.png

473 KB
Loading

screens/Login.png

2.62 MB
Loading

screens/Profile.png

273 KB
Loading

screens/Users.png

229 KB
Loading

src/MaterialPreset.php

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
<?php
2+
3+
namespace LaravelFrontendPresets\MaterialPreset;
4+
5+
use Illuminate\Filesystem\Filesystem;
6+
use Illuminate\Foundation\Console\Presets\Preset;
7+
8+
class MaterialPreset extends Preset
9+
{
10+
const STUBSPATH = __DIR__.'/material-stubs/';
11+
12+
/**
13+
* Install the preset.
14+
*
15+
* @return void
16+
*/
17+
public static function install()
18+
{
19+
static::updatePackages();
20+
static::updateAssets();
21+
22+
static::updateWelcomePage();
23+
static::updateAuthViews();
24+
static::updateLayoutViews();
25+
static::updateDashboardPage();
26+
27+
static::addPagesViews();
28+
29+
static::addUserManagement();
30+
31+
// static::removeNodeModules();
32+
}
33+
34+
/**
35+
* Update the given package array.
36+
*
37+
* @param array $packages
38+
* @return array
39+
*/
40+
protected static function updatePackageArray(array $packages)
41+
{
42+
return $packages;
43+
}
44+
45+
/**
46+
* Update the assets
47+
*
48+
* @return void
49+
*/
50+
protected static function updateAssets()
51+
{
52+
static::copyDirectory('resources/assets', public_path('material'));
53+
}
54+
55+
/**
56+
* Update the default welcome page file.
57+
*
58+
* @return void
59+
*/
60+
protected static function updateWelcomePage()
61+
{
62+
// remove default welcome page
63+
static::deleteResource(('views/welcome.blade.php'));
64+
65+
// copy new one from your stubs folder
66+
static::copyFile('resources/views/welcome.blade.php', resource_path('views/welcome.blade.php'));
67+
}
68+
69+
/**
70+
* Update the default dashboard page file.
71+
*
72+
* @return void
73+
*/
74+
protected static function updateDashboardPage()
75+
{
76+
// remove default welcome page
77+
static::deleteResource(('views/dashboard.blade.php'));
78+
79+
// copy new one from your stubs folder
80+
static::copyFile('resources/views/dashboard.blade.php', resource_path('views/dashboard.blade.php'));
81+
}
82+
83+
/**
84+
* Update the default layout files
85+
*
86+
* @return void
87+
*/
88+
protected static function updateLayoutViews()
89+
{
90+
// copy new one from your stubs folder
91+
static::copyDirectory('resources/views/layouts', resource_path('views/layouts'));
92+
}
93+
94+
/**
95+
* Copy Auth view templates.
96+
*
97+
* @return void
98+
*/
99+
protected static function updateAuthViews()
100+
{
101+
// Add Home controller
102+
static::copyFile('app/Http/Controllers/HomeController.php', app_path('Http/Controllers/HomeController.php'));
103+
104+
// Add Auth routes in 'routes/web.php'
105+
file_put_contents(
106+
'./routes/web.php',
107+
"Auth::routes();\n\nRoute::get('/home', 'HomeController@index')->name('home')->middleware('auth');\n\n",
108+
FILE_APPEND
109+
);
110+
111+
// Copy argon auth views from the stubs folder
112+
static::deleteResource('views/home.blade.php');
113+
static::copyDirectory('resources/views/auth', resource_path('views/auth'));
114+
}
115+
116+
/**
117+
* Copy user management and profile edit files
118+
*
119+
* @return void
120+
*/
121+
public static function addUserManagement()
122+
{
123+
// Add seeder, controllers, requests and rules
124+
static::copyDirectory('database/seeds', app_path('../database/seeds'));
125+
126+
static::copyFile('app/Http/Controllers/UserController.php', app_path('Http/Controllers/UserController.php'));
127+
static::copyFile('app/Http/Controllers/ProfileController.php', app_path('Http/Controllers/ProfileController.php'));
128+
static::copyDirectory('app/Http/Requests', app_path('Http/Requests'));
129+
static::copyDirectory('app/Rules', app_path('Rules'));
130+
131+
// Add routes
132+
file_put_contents(
133+
'./routes/web.php',
134+
"Route::group(['middleware' => 'auth'], function () {\n\tRoute::resource('user', 'UserController', ['except' => ['show']]);\n\tRoute::get('profile', ['as' => 'profile.edit', 'uses' => 'ProfileController@edit']);\n\tRoute::put('profile', ['as' => 'profile.update', 'uses' => 'ProfileController@update']);\n\tRoute::put('profile/password', ['as' => 'profile.password', 'uses' => 'ProfileController@password']);\n});\n\n",
135+
FILE_APPEND
136+
);
137+
138+
// Copy views
139+
static::copyDirectory('resources/views/users', resource_path('views/users'));
140+
static::copyDirectory('resources/views/profile', resource_path('views/profile'));
141+
}
142+
143+
/**
144+
* Copy internal pages files
145+
*
146+
* @return void
147+
*/
148+
public static function addPagesViews()
149+
{
150+
// Add routes
151+
file_put_contents(
152+
'./routes/web.php',
153+
"Route::group(['middleware' => 'auth'], function () {\n\tRoute::get('table-list', function () {\n\t\treturn view('pages.table_list');\n\t})->name('table');\n\n\tRoute::get('typography', function () {\n\t\treturn view('pages.typography');\n\t})->name('typography');\n\n\tRoute::get('icons', function () {\n\t\treturn view('pages.icons');\n\t})->name('icons');\n\n\tRoute::get('map', function () {\n\t\treturn view('pages.map');\n\t})->name('map');\n\n\tRoute::get('notifications', function () {\n\t\treturn view('pages.notifications');\n\t})->name('notifications');\n\n\tRoute::get('rtl-support', function () {\n\t\treturn view('pages.language');\n\t})->name('language');\n\n\tRoute::get('upgrade', function () {\n\t\treturn view('pages.upgrade');\n\t})->name('upgrade');\n});\n\n",
154+
FILE_APPEND
155+
);
156+
157+
// Copy views
158+
static::copyDirectory('resources/views/pages', resource_path('views/pages'));
159+
}
160+
161+
/**
162+
* Delete a resource
163+
*
164+
* @param string $resource
165+
* @return void
166+
*/
167+
private static function deleteResource($resource)
168+
{
169+
(new Filesystem)->delete(resource_path($resource));
170+
}
171+
172+
/**
173+
* Copy a directory
174+
*
175+
* @param string $file
176+
* @param string $destination
177+
* @return void
178+
*/
179+
private static function copyFile($file, $destination)
180+
{
181+
(new Filesystem)->copy(static::STUBSPATH.$file, $destination);
182+
}
183+
184+
/**
185+
* Copy a directory
186+
*
187+
* @param string $directory
188+
* @param string $destination
189+
* @return void
190+
*/
191+
private static function copyDirectory($directory, $destination)
192+
{
193+
(new Filesystem)->copyDirectory(static::STUBSPATH.$directory, $destination);
194+
}
195+
}

0 commit comments

Comments
 (0)