Skip to content

Commit 63ba76f

Browse files
committed
Initial release
1 parent 65f52c0 commit 63ba76f

File tree

1,761 files changed

+48986
-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.

1,761 files changed

+48986
-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 `Argon` frontend preset for Laravel will be documented in this file.
4+
5+
## Version 1.0.0
6+
7+
### Added
8+
- Argon v1.0.0 frontend theme
9+
- Laravel Auth preset
10+
- Change user profile
11+
- User CRUD

composer.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "laravel-frontend-presets/argon",
3+
"description": "Laravel 5.x Front-end preset for argon",
4+
"license": "MIT",
5+
"homepage": "https://github.com/creativetimofficial/argon-dashboard",
6+
"keywords": ["Laravel", "Preset", "Argon"],
7+
"require": {
8+
"laravel/framework": "5.5.*"
9+
},
10+
"autoload": {
11+
"psr-4": {
12+
"LaravelFrontendPresets\\ArgonPreset\\": "src/"
13+
}
14+
},
15+
"extra": {
16+
"laravel": {
17+
"providers": [
18+
"LaravelFrontendPresets\\ArgonPreset\\ArgonPresetServiceProvider"
19+
]
20+
}
21+
}
22+
}

license.md

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

readme.md

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
# Argon Frontend Preset For Laravel Framework 5.5 and Up
2+
3+
Argon Frontend Preset For Laravel Framework 5.5 and Up
4+
5+
*Current version*: Argon v1.0.0. More info at https://github.com/creativetimofficial/argon-dashboard.
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+
## Installation
12+
13+
After initializing a fresh instance of Laravel (and making all the necessary configurations), install the preset using one of the provided methods:
14+
15+
### Via composer
16+
17+
1. `Cd` to your Laravel app
18+
2. Install this preset via `composer require laravel-frontend-presets/argon`. No need to register the service provider. Laravel 5.5 & up can auto detect the package.
19+
3. Run `php artisan preset argon` 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`
20+
(NOTE: If you run this command several times, be sure to clean up the duplicate Auth entries in routes/web.php)
21+
4. Run `php artisan migrate --seed` to create basic users table
22+
23+
### By using the archive
24+
25+
1. In your application's root create a presets folder
26+
2. Paste the files from the archive in it
27+
3. Open `composer.json` file
28+
4. Add `"LaravelFrontendPresets\\ArgonPreset\\": "presets/LaravelFrontendPresets/ArgonPreset/src"` to `autoload/psr-4` and to `autoload-dev/psr-4`
29+
5. Add `LaravelFrontendPresets\ArgonPreset\ArgonPresetServiceProvider::class` to `config/app.php` file
30+
6. In your terminal run `composer dump-autoload`
31+
7. Run `php artisan preset argon` 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`
32+
(NOTE: If you run this command several times, be sure to clean up the duplicate Auth entries in routes/web.php)
33+
8. Run `php artisan migrate --seed` to create basic users table
34+
35+
36+
## Usage
37+
38+
Register a user or login using **admin@argon.com** and **secret** and start testing the preset (make sure to run the migrations and seeders for these credentials to be available).
39+
40+
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.
41+
42+
### Dashboard
43+
44+
You can access the dashboard either by using the "**Dashboard**" link in the left sidebar or by adding **/home** in the url.
45+
46+
### Profile edit
47+
48+
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.
49+
50+
The `App\Htttp\Controlers\ProfileController` handles the update of the user information.
51+
52+
```
53+
public function update(ProfileRequest $request)
54+
{
55+
auth()->user()->update($request->all());
56+
57+
return back()->withStatus(__('Profile successfully updated.'));
58+
}
59+
```
60+
61+
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`.
62+
63+
```
64+
public function rules()
65+
{
66+
return [
67+
'old_password' => ['required', 'min:6', new CurrentPasswordCheckRule],
68+
'password' => ['required', 'min:6', 'confirmed', 'different:old_password'],
69+
'password_confirmation' => ['required', 'min:6'],
70+
];
71+
}
72+
```
73+
74+
### User management
75+
76+
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.
77+
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:
78+
79+
```
80+
<div class="form-group{{ $errors->has('name') ? ' has-danger' : '' }}">
81+
<label class="form-control-label" for="input-name">{{ __('Name') }}</label>
82+
<input type="text" name="name" id="input-name" class="form-control form-control-alternative{{ $errors->has('name') ? ' is-invalid' : '' }}" placeholder="{{ __('Name') }}" value="{{ old('name') }}" required autofocus>
83+
84+
@if ($errors->has('name'))
85+
<span class="invalid-feedback" role="alert">
86+
<strong>{{ $errors->first('name') }}</strong>
87+
</span>
88+
@endif
89+
</div>
90+
```
91+
92+
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.
93+
94+
```
95+
public function rules()
96+
{
97+
return [
98+
'name' => [
99+
'required', 'min:3'
100+
],
101+
'email' => [
102+
'required', 'email', Rule::unique((new User)->getTable())->ignore($this->route()->user->id ?? null)
103+
],
104+
'password' => [
105+
$this->route()->user ? 'nullable' : 'required', 'confirmed', 'min:6'
106+
]
107+
];
108+
}
109+
```
110+
111+
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).
112+
113+
All the sample code for the user management can be found in `App\Http\Controllers\UserController`. See store method example bellow:
114+
115+
```
116+
public function store(UserRequest $request, User $model)
117+
{
118+
$model->create($request->merge(['password' => bcrypt($request->get('password'))])->all());
119+
120+
return redirect()->route('user.index')->withStatus(__('User successfully created.'));
121+
}
122+
```
123+
124+
## Change log
125+
126+
Please see the [changelog](changelog.md) for more information on what has changed recently.
127+
128+
## Credits
129+
130+
- [Creative Tim](https://creative-tim.com/)
131+
- [Updivision](https://updivision.com)
132+
133+
## License
134+
135+
The MIT License (MIT).
136+
137+
## Screen shots
138+
139+
![Argon Login](/screens/Login.png)
140+
141+
![Argon Dashboard](/screens/Dashboard.png)
142+
143+
![Argon Users](/screens/Users.png)
144+
145+
![Argon Profile](/screens/Profile.png)

screens/Dashboard.png

358 KB
Loading

screens/Login.png

208 KB
Loading

screens/Profile.png

602 KB
Loading

screens/Users.png

190 KB
Loading

src/ArgonPreset.php

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
<?php
2+
3+
namespace LaravelFrontendPresets\ArgonPreset;
4+
5+
use Illuminate\Filesystem\Filesystem;
6+
use Illuminate\Foundation\Console\Presets\Preset;
7+
8+
class ArgonPreset extends Preset
9+
{
10+
const STUBSPATH = __DIR__.'/argon-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::addUserManagement();
28+
29+
// static::removeNodeModules();
30+
}
31+
32+
/**
33+
* Update the given package array.
34+
*
35+
* @param array $packages
36+
* @return array
37+
*/
38+
protected static function updatePackageArray(array $packages)
39+
{
40+
return $packages;
41+
}
42+
43+
/**
44+
* Update the assets
45+
*
46+
* @return void
47+
*/
48+
protected static function updateAssets()
49+
{
50+
static::copyDirectory('resources/assets', public_path('argon'));
51+
}
52+
53+
/**
54+
* Update the default welcome page file.
55+
*
56+
* @return void
57+
*/
58+
protected static function updateWelcomePage()
59+
{
60+
// remove default welcome page
61+
static::deleteResource(('views/welcome.blade.php'));
62+
63+
// copy new one from your stubs folder
64+
static::copyFile('resources/views/welcome.blade.php', resource_path('views/welcome.blade.php'));
65+
}
66+
67+
/**
68+
* Update the default dashboard page file.
69+
*
70+
* @return void
71+
*/
72+
protected static function updateDashboardPage()
73+
{
74+
// remove default welcome page
75+
static::deleteResource(('views/dashboard.blade.php'));
76+
77+
// copy new one from your stubs folder
78+
static::copyFile('resources/views/dashboard.blade.php', resource_path('views/dashboard.blade.php'));
79+
}
80+
81+
/**
82+
* Update the default layout files
83+
*
84+
* @return void
85+
*/
86+
protected static function updateLayoutViews()
87+
{
88+
// copy new one from your stubs folder
89+
static::copyDirectory('resources/views/layouts', resource_path('views/layouts'));
90+
}
91+
92+
/**
93+
* Copy Auth view templates.
94+
*
95+
* @return void
96+
*/
97+
protected static function updateAuthViews()
98+
{
99+
// Add Home controller
100+
static::copyFile('app/Http/Controllers/HomeController.php', app_path('Http/Controllers/HomeController.php'));
101+
102+
// Add Auth routes in 'routes/web.php'
103+
file_put_contents(
104+
'./routes/web.php',
105+
"Auth::routes();\n\nRoute::get('/home', 'HomeController@index')->name('home');\n\n",
106+
FILE_APPEND
107+
);
108+
109+
// Copy argon auth views from the stubs folder
110+
static::deleteResource('views/home.blade.php');
111+
static::copyDirectory('resources/views/auth', resource_path('views/auth'));
112+
}
113+
114+
/**
115+
* Copy user management and profile edit files
116+
*
117+
* @return void
118+
*/
119+
public static function addUserManagement()
120+
{
121+
// Add seeder, controllers, requests and rules
122+
static::copyDirectory('database/seeds', app_path('../database/seeds'));
123+
124+
static::copyFile('app/Http/Controllers/UserController.php', app_path('Http/Controllers/UserController.php'));
125+
static::copyFile('app/Http/Controllers/ProfileController.php', app_path('Http/Controllers/ProfileController.php'));
126+
static::copyDirectory('app/Http/Requests', app_path('Http/Requests'));
127+
static::copyDirectory('app/Rules', app_path('Rules'));
128+
129+
// Add routes
130+
file_put_contents(
131+
'./routes/web.php',
132+
"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",
133+
FILE_APPEND
134+
);
135+
136+
// Copy views
137+
static::copyDirectory('resources/views/users', resource_path('views/users'));
138+
static::copyDirectory('resources/views/profile', resource_path('views/profile'));
139+
}
140+
141+
/**
142+
* Delete a resource
143+
*
144+
* @param string $resource
145+
* @return void
146+
*/
147+
private static function deleteResource($resource)
148+
{
149+
(new Filesystem)->delete(resource_path($resource));
150+
}
151+
152+
/**
153+
* Copy a directory
154+
*
155+
* @param string $file
156+
* @param string $destination
157+
* @return void
158+
*/
159+
private static function copyFile($file, $destination)
160+
{
161+
(new Filesystem)->copy(static::STUBSPATH.$file, $destination);
162+
}
163+
164+
/**
165+
* Copy a directory
166+
*
167+
* @param string $directory
168+
* @param string $destination
169+
* @return void
170+
*/
171+
private static function copyDirectory($directory, $destination)
172+
{
173+
(new Filesystem)->copyDirectory(static::STUBSPATH.$directory, $destination);
174+
}
175+
}

0 commit comments

Comments
 (0)