Skip to content

Commit 4792e2d

Browse files
author
Mohamad Murad
committed
Initial commit
0 parents  commit 4792e2d

File tree

246 files changed

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

246 files changed

+42646
-0
lines changed

.editorconfig

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.{yml,yaml}]
15+
indent_size = 2
16+
17+
[docker-compose.yml]
18+
indent_size = 4

.env.example

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
APP_NAME=Laravel
2+
APP_ENV=local
3+
APP_KEY=
4+
APP_DEBUG=true
5+
APP_URL=http://localhost
6+
7+
LOG_CHANNEL=stack
8+
LOG_DEPRECATIONS_CHANNEL=null
9+
LOG_LEVEL=debug
10+
11+
DB_CONNECTION=mysql
12+
DB_HOST=127.0.0.1
13+
DB_PORT=3306
14+
DB_DATABASE=b
15+
DB_USERNAME=root
16+
DB_PASSWORD=
17+
18+
BROADCAST_DRIVER=log
19+
CACHE_DRIVER=file
20+
FILESYSTEM_DRIVER=local
21+
QUEUE_CONNECTION=sync
22+
SESSION_DRIVER=file
23+
SESSION_LIFETIME=120
24+
25+
MEMCACHED_HOST=127.0.0.1
26+
27+
REDIS_HOST=127.0.0.1
28+
REDIS_PASSWORD=null
29+
REDIS_PORT=6379
30+
31+
MAIL_MAILER=smtp
32+
MAIL_HOST=mailhog
33+
MAIL_PORT=1025
34+
MAIL_USERNAME=null
35+
MAIL_PASSWORD=null
36+
MAIL_ENCRYPTION=null
37+
MAIL_FROM_ADDRESS=null
38+
MAIL_FROM_NAME="${APP_NAME}"
39+
40+
AWS_ACCESS_KEY_ID=
41+
AWS_SECRET_ACCESS_KEY=
42+
AWS_DEFAULT_REGION=us-east-1
43+
AWS_BUCKET=
44+
AWS_USE_PATH_STYLE_ENDPOINT=false
45+
46+
PUSHER_APP_ID=
47+
PUSHER_APP_KEY=
48+
PUSHER_APP_SECRET=
49+
PUSHER_APP_CLUSTER=mt1
50+
51+
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
52+
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

.gitattributes

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
* text=auto
2+
3+
*.blade.php diff=html
4+
*.css diff=css
5+
*.html diff=html
6+
*.md diff=markdown
7+
*.php diff=php
8+
9+
/.github export-ignore
10+
CHANGELOG.md export-ignore

.gitignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/node_modules
2+
/public/hot
3+
/public/storage
4+
/storage/*.key
5+
/vendor
6+
.env
7+
.env.backup
8+
.phpunit.result.cache
9+
docker-compose.override.yml
10+
Homestead.json
11+
Homestead.yaml
12+
npm-debug.log
13+
yarn-error.log
14+
/.idea
15+
/.vscode

.styleci.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
php:
2+
preset: laravel
3+
version: 8
4+
disabled:
5+
- no_unused_imports
6+
finder:
7+
not-name:
8+
- index.php
9+
- server.php
10+
js:
11+
finder:
12+
not-name:
13+
- webpack.mix.js
14+
css: true

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2022 Mohamad Murad <[email protected]>
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

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<h1>Laravel ReactJS Dashboard</h1>
2+
3+
<h2>A laravel dashboard built in InertiaJs + ReactJs</h2>
4+
<p>Laravel + Bootstrap + ReactJS + InertiaJS + laravel-permission </p>
5+
6+
<h2>Screenshot</h2>
7+
![public/screen/login.png](public/screen/login.png)
8+
![public/screen/screen1.png](public/screen/screen1.png)
9+
![public/screen/screen2.png](public/screen/screen2.png)
10+
11+
12+
<h3>Setup</h3>
13+
```bash
14+
#install composer dependency
15+
composer install
16+
# copy .env.example to .env
17+
cp .env.example .env
18+
# generate security key , link storage file
19+
php artisan key:generate
20+
php artisan storage:link
21+
# after connect your database via .env file
22+
php artisan migrate:fresh
23+
php artisan db:seed
24+
```
25+
26+
<h3>Credentials</h3>
27+
```
28+
login url : <http://127.0.0.1:8000/login>
29+
30+
password : password
31+
```
32+
33+
34+
<h2>Built With</h2>
35+
* [Laravel](https://laravel.com/)
36+
* [ReactJs](https://reactjs.org/)
37+
* [InertiaJS](https://inertiajs.com/)
38+
* [Bootstrap](https://getbootstrap.com/)
39+
40+
<h2>Contributing</h2>
41+
Thank you for contributing to this repository.
42+
43+
<h2>Acknowledgments</h2>
44+
We acknowledge and are grateful to these developers for their contributions to open source.
45+
* [Volt React Dashboard](https://demo.themesberg.com/volt-react-dashboard/#/)
46+
* [laravel-permission](https://spatie.be/docs/laravel-permission/v5/introduction)
47+
48+
49+
<h2>License</h2>
50+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details

app/Console/Kernel.php

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace App\Console;
4+
5+
use Illuminate\Console\Scheduling\Schedule;
6+
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
7+
8+
class Kernel extends ConsoleKernel
9+
{
10+
/**
11+
* Define the application's command schedule.
12+
*
13+
* @param \Illuminate\Console\Scheduling\Schedule $schedule
14+
* @return void
15+
*/
16+
protected function schedule(Schedule $schedule)
17+
{
18+
// $schedule->command('inspire')->hourly();
19+
}
20+
21+
/**
22+
* Register the commands for the application.
23+
*
24+
* @return void
25+
*/
26+
protected function commands()
27+
{
28+
$this->load(__DIR__.'/Commands');
29+
30+
require base_path('routes/console.php');
31+
}
32+
}

app/Exceptions/Handler.php

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
namespace App\Exceptions;
4+
5+
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
6+
use Throwable;
7+
8+
class Handler extends ExceptionHandler
9+
{
10+
/**
11+
* A list of the exception types that are not reported.
12+
*
13+
* @var array<int, class-string<Throwable>>
14+
*/
15+
protected $dontReport = [
16+
//
17+
];
18+
19+
/**
20+
* A list of the inputs that are never flashed for validation exceptions.
21+
*
22+
* @var array<int, string>
23+
*/
24+
protected $dontFlash = [
25+
'current_password',
26+
'password',
27+
'password_confirmation',
28+
];
29+
30+
/**
31+
* Register the exception handling callbacks for the application.
32+
*
33+
* @return void
34+
*/
35+
public function register()
36+
{
37+
$this->reportable(function (Throwable $e) {
38+
//
39+
});
40+
}
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Admin;
4+
5+
use App\Http\Controllers\Controller;
6+
use App\Http\Requests\admin\roles\StoreRoleRequest;
7+
use App\Http\Requests\admin\roles\UpdateRoleRequest;
8+
use App\Models\User;
9+
use Illuminate\Http\RedirectResponse;
10+
use Illuminate\Http\Request;
11+
use Illuminate\Support\Facades\Auth;
12+
use Illuminate\Support\Facades\Gate;
13+
use Inertia\Inertia;
14+
use Spatie\Permission\Models\Permission;
15+
use Spatie\Permission\Models\Role;
16+
use Symfony\Component\HttpFoundation\Response;
17+
18+
class RolesController extends Controller
19+
{
20+
/**
21+
* Display a listing of the resource.
22+
*
23+
* @return \Inertia\Response
24+
*/
25+
public function index()
26+
{
27+
abort_if(!Auth::user()->can('role_access'), Response::HTTP_FORBIDDEN, '403 Forbidden');
28+
29+
$roles = Role::with(['permissions'])->get();
30+
return Inertia::render('admin/roles/index', [
31+
'roles' => $roles
32+
]);
33+
34+
}
35+
36+
/**
37+
* Show the form for creating a new resource.
38+
*
39+
* @return \Illuminate\Http\Response
40+
*/
41+
public function create()
42+
{
43+
abort_if(!Auth::user()->can('user_create'), Response::HTTP_FORBIDDEN, '403 Forbidden');
44+
45+
$permissions = Permission::select('id AS value' , 'name AS label')->get();
46+
47+
return Inertia::render('admin/roles/create', [
48+
'permissions' => $permissions
49+
]);
50+
}
51+
52+
/**
53+
* Store a newly created resource in storage.
54+
*
55+
* @param StoreRoleRequest $request
56+
* @return RedirectResponse
57+
*/
58+
public function store(StoreRoleRequest $request)
59+
{
60+
$permissions = $request->get('permissions');
61+
$role = Role::create(['name' => $request->get('name')]);
62+
$role->syncPermissions($permissions);
63+
return redirect()->route('admin.roles.index');
64+
}
65+
66+
/**
67+
* Display the specified resource.
68+
*
69+
* @param int $id
70+
* @return \Illuminate\Http\Response
71+
*/
72+
public function show($id)
73+
{
74+
abort_if(!Auth::user()->can('role_show'), Response::HTTP_FORBIDDEN, '403 Forbidden');
75+
}
76+
77+
/**
78+
* Show the form for editing the specified resource.
79+
*
80+
* @param int $id
81+
* @return \Inertia\Response
82+
*/
83+
public function edit(Role $role)
84+
{
85+
abort_if(!Auth::user()->can('role_edit'), Response::HTTP_FORBIDDEN, '403 Forbidden');
86+
$permissions = Permission::select('id AS value' , 'name AS label')->get();
87+
88+
$role->load('permissions');
89+
return Inertia::render('admin/roles/edit',[
90+
'role' => $role,
91+
'permissions' => $permissions,
92+
]);
93+
}
94+
95+
/**
96+
* Update the specified resource in storage.
97+
*
98+
* @param Request $request
99+
* @param int $id
100+
* @return \Illuminate\Http\Response
101+
*/
102+
public function update(UpdateRoleRequest $request, Role $role)
103+
{
104+
$permissions = $request->get('permissions');
105+
$role->update([
106+
'name' => $request->get('name'),
107+
]);
108+
$role->syncPermissions($permissions);
109+
return redirect()->route('admin.roles.index');
110+
}
111+
112+
/**
113+
* Remove the specified resource from storage.
114+
*
115+
* @param int $id
116+
* @return \Illuminate\Http\Response
117+
*/
118+
public function destroy(Role $role)
119+
{
120+
abort_if(!Auth::user()->can('role_delete'), Response::HTTP_FORBIDDEN, '403 Forbidden');
121+
$users = User::role($role->name)->count();
122+
123+
if ($users) {
124+
return back()->with('error', 'This role assined to users , please change users role before delete it');
125+
}
126+
$role->delete();
127+
return back();
128+
}
129+
}

0 commit comments

Comments
 (0)