Skip to content

Commit 760965f

Browse files
authored
Merge pull request #12 from balajidharma/1.x
merge changes
2 parents 7226bd1 + af0d821 commit 760965f

Some content is hidden

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

52 files changed

+1175
-25195
lines changed

LICENSE

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) Balaji Dharma
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: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,40 @@
55
<a href="https://packagist.org/packages/balajidharma/basic-laravel-admin-panel"><img src="https://poser.pugx.org/balajidharma/basic-laravel-admin-panel/v/stable" alt="Latest Stable Version"></a>
66
<a href="https://packagist.org/packages/balajidharma/basic-laravel-admin-panel"><img src="https://poser.pugx.org/balajidharma/basic-laravel-admin-panel/license" alt="License"></a>
77
</p>
8-
<p align="center"><img src="https://miro.medium.com/max/1400/1*3eXlUx9DnzjgXX_1PJ_qWw.png" width="600"></a>
8+
9+
## Built with
10+
- [Laravel 9](https://github.com/laravel/framework)
11+
- [spatie/laravel-permission](https://github.com/spatie/laravel-permission)
12+
- [Laravel Breeze](https://github.com/laravel/breeze)
13+
- [Tailwind CSS](https://tailwindcss.com/)
14+
915

1016
## Installation
11-
- Clone the repository with __git clone__
12-
- `./vendor/bin/sail up`
13-
- `sail artisan breeze:install`
14-
- `sail artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider"`
15-
- `npm install && npm run dev`
16-
- `sail artisan migrate --seed --seeder=BasicAdminPermissionSeeder`
17+
- To get started, you need to install [Docker Desktop](https://www.docker.com/products/docker-desktop).
18+
- You may run the following command in your terminal
19+
- Windows open WSL2 Linux terminal. [Docker Desktop WSL 2 backend](https://docs.docker.com/desktop/windows/wsl/)
20+
- `docker run --rm -v "$(pwd)":/opt -w /opt laravelsail/php81-composer:latest bash -c "composer create-project balajidharma/basic-laravel-admin-panel admin-app && cd admin-app && php ./artisan sail:install --with=mysql,redis,meilisearch,mailhog,selenium"`
21+
- `cd admin-app && ./vendor/bin/sail up`
22+
- `./vendor/bin/sail npm install`
23+
- `./vendor/bin/sail npm run dev`
24+
- `./vendor/bin/sail artisan migrate --seed --seeder=BasicAdminPermissionSeeder`
25+
- Now open http://localhost/
26+
27+
###### Super Admin Login
28+
29+
- Password - password
30+
31+
## Screenshots
32+
<p align="center">
33+
<img src="https://miro.medium.com/max/700/1*Wk4WaomlQ4v_GKUY2AhcXw.png" >
34+
<br/><br/>
35+
<img src="https://miro.medium.com/max/700/1*3eXlUx9DnzjgXX_1PJ_qWw.png" >
36+
<br/><br/>
37+
<img src="https://miro.medium.com/max/700/1*jtzIchs6RP-leKp3nugdZw.png" >
38+
<br/><br/>
39+
<img src="https://miro.medium.com/max/700/1*4LFqQCnriBDipDpbvcnCzw.png">
40+
</p>
1741

1842
## License
1943

20-
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
44+
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
namespace App\Actions\Admin\User;
3+
4+
use App\Models\User;
5+
use Illuminate\Http\Request;
6+
use Illuminate\Support\Facades\Hash;
7+
8+
class CreateUser
9+
{
10+
public function handle(Request $request): User
11+
{
12+
$user = User::create([
13+
'name' => $request->name,
14+
'email' => $request->email,
15+
'password' => Hash::make($request->password),
16+
]);
17+
18+
$roles = $request->roles ?? [];
19+
$user->assignRole($roles);
20+
21+
return $user;
22+
}
23+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
namespace App\Actions\Admin\User;
3+
4+
use App\Models\User;
5+
use Illuminate\Http\Request;
6+
use Illuminate\Support\Facades\Hash;
7+
8+
class UpdateUser
9+
{
10+
public function handle(Request $request, User $user): User
11+
{
12+
$user->update([
13+
'name' => $request->name,
14+
'email' => $request->email,
15+
]);
16+
17+
if($request->password){
18+
$user->update([
19+
'password' => Hash::make($request->password),
20+
]);
21+
}
22+
23+
$roles = $request->roles ?? [];
24+
$user->syncRoles($roles);
25+
26+
return $user;
27+
}
28+
}

app/Http/Controllers/Admin/PermissionController.php

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
namespace App\Http\Controllers\Admin;
44

55
use App\Http\Controllers\Controller;
6+
use App\Http\Requests\Admin\StorePermissionRequest;
7+
use App\Http\Requests\Admin\UpdatePermissionRequest;
68
use App\Models\Permission;
79
use Illuminate\Http\Request;
810

@@ -59,19 +61,15 @@ public function create()
5961
/**
6062
* Store a newly created resource in storage.
6163
*
62-
* @param \Illuminate\Http\Request $request
64+
* @param \App\Http\Requests\Admin\StorePermissionRequest $request
6365
* @return \Illuminate\Http\Response
6466
*/
65-
public function store(Request $request)
67+
public function store(StorePermissionRequest $request)
6668
{
67-
$request->validate([
68-
'name' => 'required|string|max:255|unique:'.config('permission.table_names.permissions', 'permissions').',name',
69-
]);
70-
7169
Permission::create($request->all());
7270

7371
return redirect()->route('permission.index')
74-
->with('message','Permission created successfully.');
72+
->with('message', __('Permission created successfully.'));
7573
}
7674

7775
/**
@@ -99,20 +97,16 @@ public function edit(Permission $permission)
9997
/**
10098
* Update the specified resource in storage.
10199
*
102-
* @param \Illuminate\Http\Request $request
100+
* @param \App\Http\Requests\Admin\UpdatePermissionRequest $request
103101
* @param \App\Models\Permission $permission
104102
* @return \Illuminate\Http\Response
105103
*/
106-
public function update(Request $request, Permission $permission)
104+
public function update(UpdatePermissionRequest $request, Permission $permission)
107105
{
108-
$request->validate([
109-
'name' => 'required|string|max:255|unique:'.config('permission.table_names.permissions', 'permissions').',name,'.$permission->id,
110-
]);
111-
112106
$permission->update($request->all());
113107

114108
return redirect()->route('permission.index')
115-
->with('message','Permission updated successfully.');
109+
->with('message', __('Permission updated successfully.'));
116110
}
117111

118112
/**
@@ -126,6 +120,6 @@ public function destroy(Permission $permission)
126120
$permission->delete();
127121

128122
return redirect()->route('permission.index')
129-
->with('message','Permission deleted successfully');
123+
->with('message', __('Permission deleted successfully'));
130124
}
131125
}

app/Http/Controllers/Admin/RoleController.php

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
namespace App\Http\Controllers\Admin;
44

55
use App\Http\Controllers\Controller;
6+
use App\Http\Requests\Admin\StoreRoleRequest;
7+
use App\Http\Requests\Admin\UpdateRoleRequest;
68
use App\Models\Role;
79
use App\Models\Permission;
810
use Illuminate\Http\Request;
@@ -61,15 +63,11 @@ public function create()
6163
/**
6264
* Store a newly created resource in storage.
6365
*
64-
* @param \Illuminate\Http\Request $request
66+
* @param \App\Http\Requests\Admin\StoreRoleRequest $request
6567
* @return \Illuminate\Http\Response
6668
*/
67-
public function store(Request $request)
69+
public function store(StoreRoleRequest $request)
6870
{
69-
$request->validate([
70-
'name' => 'required|string|max:255|unique:'.config('permission.table_names.roles', 'roles').',name',
71-
]);
72-
7371
$role = Role::create($request->all());
7472

7573
if(! empty($request->permissions)) {
@@ -110,16 +108,12 @@ public function edit(Role $role)
110108
/**
111109
* Update the specified resource in storage.
112110
*
113-
* @param \Illuminate\Http\Request $request
111+
* @param \App\Http\Requests\Admin\UpdateRoleRequest $request
114112
* @param \App\Models\Role $role
115113
* @return \Illuminate\Http\Response
116114
*/
117-
public function update(Request $request, Role $role)
115+
public function update(UpdateRoleRequest $request, Role $role)
118116
{
119-
$request->validate([
120-
'name' => 'required|string|max:255|unique:'.config('permission.table_names.roles', 'roles').',name,'.$role->id,
121-
]);
122-
123117
$role->update($request->all());
124118
$permissions = $request->permissions ?? [];
125119
$role->syncPermissions($permissions);
@@ -139,6 +133,6 @@ public function destroy(Role $role)
139133
$role->delete();
140134

141135
return redirect()->route('role.index')
142-
->with('message','Role deleted successfully');
136+
->with('message', __('Role deleted successfully'));
143137
}
144138
}

0 commit comments

Comments
 (0)