toastr added

This commit is contained in:
Dharmaraj Shrestha 2024-04-04 13:31:19 +05:45
parent c969cdabcc
commit 2f839afe6b
15 changed files with 420 additions and 18 deletions

View File

@ -0,0 +1,44 @@
<?php
namespace App\Http\Controllers;
use App\DataTables\UsersDataTable;
use App\Models\User;
use Illuminate\Http\Request;
use Spatie\Permission\Models\Role;
class UserController extends Controller
{
public function create()
{
$roles = Role::all();
return view('users.create', compact('roles'));
}
public function store(Request $request)
{
$validatedData = $request->validate([
'name' => 'required|min:5',
'email' => 'required',
'password' => 'required',
'role' => 'required',
]);
$user = User::create($validatedData);
$user->roles()->attach($request->role);
toastr()->success('User has been created!');
return redirect()->route('users.index');
}
public function index(UsersDataTable $dataTables)
{
return $dataTables->render('users.index');
}
public function destroy(string $id)
{
$user = User::findOrFail($id);
$user->delete();
toastr()->success('Data has been deleted successfully!');
return redirect()->back();
}
}

View File

@ -63,5 +63,8 @@ class Kernel extends HttpKernel
'signed' => \App\Http\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
'role_or_permission' => \Spatie\Permission\Middleware\RoleOrPermissionMiddleware::class,
'role' => \Spatie\Permission\Middleware\RoleMiddleware::class,
'permission' => \Spatie\Permission\Middleware\PermissionMiddleware::class,
];
}

View File

@ -11,7 +11,8 @@
"laravel/sanctum": "^3.2",
"laravel/tinker": "^2.8",
"laravel/ui": "^4.5",
"spatie/laravel-permission": "^6.4"
"spatie/laravel-permission": "^6.4",
"yoeunes/toastr": "^2.3"
},
"require-dev": {
"fakerphp/faker": "^1.9.1",

296
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "9dfe840e3949f0554256147101c42a8e",
"content-hash": "e3947aa2fb682a8822517d180dd8cc15",
"packages": [
{
"name": "brick/math",
@ -2457,6 +2457,195 @@
],
"time": "2023-02-08T01:06:31+00:00"
},
{
"name": "php-flasher/flasher",
"version": "v1.15.14",
"source": {
"type": "git",
"url": "https://github.com/php-flasher/flasher.git",
"reference": "33ae74e73f62814fff4e78e78f912d9b6ddf82d0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-flasher/flasher/zipball/33ae74e73f62814fff4e78e78f912d9b6ddf82d0",
"reference": "33ae74e73f62814fff4e78e78f912d9b6ddf82d0",
"shasum": ""
},
"require": {
"php": ">=5.3"
},
"type": "library",
"autoload": {
"files": [
"helpers.php"
],
"psr-4": {
"Flasher\\Prime\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Younes KHOUBZA",
"email": "younes.khoubza@gmail.com",
"homepage": "https://www.linkedin.com/in/younes-khoubza",
"role": "Developer"
}
],
"description": "PHPFlasher - A powerful & easy-to-use package for adding flash messages to Laravel or Symfony projects. Provides feedback to users, improves engagement & enhances user experience. Intuitive design for beginners & experienced developers. A reliable, flexible solution.",
"homepage": "https://php-flasher.io",
"keywords": [
"custom-adapter",
"dark-mode",
"desktop-notifications",
"flash-messages",
"framework-agnostic",
"javascript",
"laravel",
"notification-system",
"noty",
"notyf",
"php",
"php-flasher",
"phpstorm-auto-complete",
"pnotify",
"rtl",
"sweetalert",
"symfony",
"toastr",
"user-experience",
"user-feedback",
"yoeunes"
],
"support": {
"source": "https://github.com/php-flasher/flasher/tree/v1.15.14"
},
"funding": [
{
"url": "https://www.paypal.com/paypalme/yoeunes",
"type": "custom"
},
{
"url": "https://github.com/yoeunes",
"type": "github"
},
{
"url": "https://ko-fi.com/yoeunes",
"type": "ko_fi"
},
{
"url": "https://opencollective.com/php-flasher",
"type": "open_collective"
},
{
"url": "https://www.patreon.com/yoeunes",
"type": "patreon"
}
],
"time": "2023-12-16T17:11:36+00:00"
},
{
"name": "php-flasher/flasher-laravel",
"version": "v1.15.14",
"source": {
"type": "git",
"url": "https://github.com/php-flasher/flasher-laravel.git",
"reference": "c2777483fd7074087c16f861ce2191a95088e7c6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-flasher/flasher-laravel/zipball/c2777483fd7074087c16f861ce2191a95088e7c6",
"reference": "c2777483fd7074087c16f861ce2191a95088e7c6",
"shasum": ""
},
"require": {
"illuminate/support": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0",
"php": ">=5.3",
"php-flasher/flasher": "^1.15.14"
},
"type": "library",
"extra": {
"laravel": {
"aliases": {
"Flasher": "Flasher\\Laravel\\Facade\\Flasher"
},
"providers": [
"Flasher\\Laravel\\FlasherServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Flasher\\Laravel\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Younes KHOUBZA",
"email": "younes.khoubza@gmail.com",
"homepage": "https://www.linkedin.com/in/younes-khoubza",
"role": "Developer"
}
],
"description": "PHPFlasher - A powerful & easy-to-use package for adding flash messages to Laravel or Symfony projects. Provides feedback to users, improves engagement & enhances user experience. Intuitive design for beginners & experienced developers. A reliable, flexible solution.",
"homepage": "https://php-flasher.io",
"keywords": [
"custom-adapter",
"dark-mode",
"desktop-notifications",
"flash-messages",
"framework-agnostic",
"javascript",
"laravel",
"notification-system",
"noty",
"notyf",
"php",
"php-flasher",
"phpstorm-auto-complete",
"pnotify",
"rtl",
"sweetalert",
"symfony",
"toastr",
"user-experience",
"user-feedback",
"yoeunes"
],
"support": {
"source": "https://github.com/php-flasher/flasher-laravel/tree/v1.15.14"
},
"funding": [
{
"url": "https://www.paypal.com/paypalme/yoeunes",
"type": "custom"
},
{
"url": "https://github.com/yoeunes",
"type": "github"
},
{
"url": "https://ko-fi.com/yoeunes",
"type": "ko_fi"
},
{
"url": "https://opencollective.com/php-flasher",
"type": "open_collective"
},
{
"url": "https://www.patreon.com/yoeunes",
"type": "patreon"
}
],
"time": "2024-03-16T15:25:14+00:00"
},
{
"name": "phpoption/phpoption",
"version": "1.9.2",
@ -5829,6 +6018,111 @@
"source": "https://github.com/webmozarts/assert/tree/1.11.0"
},
"time": "2022-06-03T18:03:27+00:00"
},
{
"name": "yoeunes/toastr",
"version": "v2.3.5",
"source": {
"type": "git",
"url": "https://github.com/yoeunes/toastr.git",
"reference": "5c39d42b4c7b110572b7643bba1cd51b8af89b74"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/yoeunes/toastr/zipball/5c39d42b4c7b110572b7643bba1cd51b8af89b74",
"reference": "5c39d42b4c7b110572b7643bba1cd51b8af89b74",
"shasum": ""
},
"require": {
"php": ">=5.3",
"php-flasher/flasher-laravel": "^1.15.14"
},
"type": "library",
"extra": {
"laravel": {
"aliases": {
"Toastr": "Yoeunes\\Toastr\\Facades\\Toastr"
},
"providers": [
"Yoeunes\\Toastr\\ToastrServiceProvider"
]
}
},
"autoload": {
"files": [
"src/helpers.php"
],
"psr-4": {
"Yoeunes\\Toastr\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Younes KHOUBZA",
"email": "younes.khoubza@gmail.com",
"homepage": "https://www.linkedin.com/in/younes-khoubza",
"role": "Developer"
}
],
"description": "toastr.js flush notifications for Laravel",
"homepage": "https://github.com/yoeunes/toastr",
"keywords": [
"custom-adapter",
"dark-mode",
"desktop-notifications",
"flash-messages",
"framework-agnostic",
"javascript",
"laravel",
"notification-system",
"noty",
"notyf",
"php",
"php-flasher",
"phpstorm-auto-complete",
"pnotify",
"rtl",
"sweetalert",
"symfony",
"toastr",
"toastr js",
"user-experience",
"user-feedback",
"yoeunes"
],
"support": {
"docs": "https://github.com/yoeunes/toastr/README.md",
"email": "younes.khoubza@gmail.com",
"issues": "https://github.com/yoeunes/toastr/issues",
"source": "https://github.com/yoeunes/toastr"
},
"funding": [
{
"url": "https://www.paypal.com/paypalme/yoeunes",
"type": "custom"
},
{
"url": "https://github.com/yoeunes",
"type": "github"
},
{
"url": "https://ko-fi.com/yoeunes",
"type": "ko_fi"
},
{
"url": "https://opencollective.com/php-flasher",
"type": "open_collective"
},
{
"url": "https://www.patreon.com/yoeunes",
"type": "patreon"
}
],
"time": "2024-03-16T15:29:23+00:00"
}
],
"packages-dev": [

19
config/flasher_toastr.php Normal file
View File

@ -0,0 +1,19 @@
<?php
/*
* This file is part of the yoeunes/toastr package.
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
*/
return array(
'scripts' => array(
'cdn' => array(
'https://cdn.jsdelivr.net/npm/jquery@3.6.3/dist/jquery.min.js',
'https://cdn.jsdelivr.net/npm/@flasher/flasher-toastr@1.2.4/dist/flasher-toastr.min.js',
),
'local' => array(
'/vendor/flasher/jquery.min.js',
'/vendor/flasher/flasher-toastr.min.js',
),
),
);

27
config/toastr.php Normal file
View File

@ -0,0 +1,27 @@
<?php
/*
* This file is part of the yoeunes/toastr package.
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
*/
return array(
/*
|--------------------------------------------------------------------------
| Toastr options
|--------------------------------------------------------------------------
|
| Here you can specify the options that will be passed to the toastr.js
| library. For a full list of options, visit the documentation.
|
| Example:
| 'options' => [
| 'closeButton' => true,
| 'debug' => false,
| 'newestOnTop' => false,
| 'progressBar' => true,
| ],
*/
'options' => array(),
);

File diff suppressed because one or more lines are too long

2
public/vendor/flasher/jquery.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,5 @@
<x-app-layout>
@extends('layouts.app')
@section('content')
<section class="section">
<div class="section-header">
<h1>Manage Permission</h1>
@ -36,4 +37,4 @@
</div>
</div>
</section>
</x-app-layout>
@endsection

View File

@ -1,4 +1,5 @@
<x-app-layout>
@extends('layouts.app')
@section('content')
<section class="section">
<div class="section-header">
<h1>Manage Permissions</h1>
@ -19,13 +20,13 @@
<div class="col-md-7">
<div class="form-group">
<label for="name">Permission Name <span class="text-danger">*</span></label>
<input id="name" class="rounded-md form-control" value="{{ old('name', $permission->name) }}"
<input id="name" class="form-control rounded-md" value="{{ old('name', $permission->name) }}"
type="text" name="name" />
</div>
</div>
</div>
<div class="row">
<div class="justify-end col-md-12 d-flex">
<div class="col-md-12 d-flex justify-end">
<button type="submit" class="btn btn-primary">Update</button>
</div>
</div>
@ -33,4 +34,4 @@
</div>
</div>
</section>
</x-app-layout>
@endsection

View File

@ -1,4 +1,5 @@
<x-app-layout>
@extends('layouts.app')
@section('content')
<section class="section">
<div class="section-header">
<h1>List Permissions</h1>
@ -51,4 +52,4 @@
</div>
</div>
</section>
</x-app-layout>
@endsection

View File

@ -1,4 +1,5 @@
<x-app-layout>
@extends('layouts.app')
@section('content')
<section class="section">
<div class="section-header">
<h1>Add New Role</h1>
@ -53,4 +54,4 @@
</div>
</div>
</section>
</x-app-layout>
@endsection

View File

@ -1,4 +1,5 @@
<x-app-layout>
@extends('layouts.app')
@section('content')
<section class="section">
<div class="section-header">
<h1>Manage Roles</h1>
@ -50,4 +51,4 @@
</div>
</div>
</section>
</x-app-layout>
@endsection

View File

@ -1,4 +1,5 @@
<x-app-layout>
@extends('layouts.app')
@section('content')
<section class="section">
<div class="section-header">
<h1>List Roles</h1>
@ -32,8 +33,8 @@
@endforeach
<td>
@can('edit roles')
<a href="{{ route('roles.edit', $role->id) }}"
class="btn btn-primary btn-sm rounded-lg text-white"><i class="fas fa-edit"></i></a>
<a href="{{ route('roles.edit', $role->id) }}" class="btn btn-primary btn-sm rounded-lg text-white"><i
class="fas fa-edit"></i></a>
@endcan
@can('delete roles')
<form method="post" action="{{ route('roles.destroy', $role->id) }}">
@ -55,4 +56,4 @@
</div>
</div>
</section>
</x-app-layout>
@endsection

View File

@ -1,5 +1,7 @@
<?php
use App\Http\Controllers\PermissionController;
use App\Http\Controllers\RoleController;
use Illuminate\Support\Facades\Route;
/*
@ -20,3 +22,6 @@ Route::get('/', function () {
Auth::routes();
Route::get('/dashboard', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
Route::resource('roles', RoleController::class)->names('roles');
Route::resource('permissions', PermissionController::class)->names('permissions');