authentikasioan dan detail
commit
5b28c697f1
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class CreateRoutePermissionCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'permission:create-permission-routes';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$routes = Route::getRoutes()->getRoutesByName();
|
||||
// dd($routes);
|
||||
foreach ($routes as $route) {
|
||||
if ($route->getName() != '' && count($route->getAction()['middleware']) >= 2) {
|
||||
$permission = Permission::where('name', $route->getName())->first();
|
||||
|
||||
$data = $route->getName();
|
||||
[$first_group] = explode('.', $data);
|
||||
$comment = $route->getComment();
|
||||
if (is_null($comment)) {
|
||||
$comment = Str::title(str_replace('.', ' ', $route->getName()));
|
||||
}
|
||||
if (is_null($permission)) {
|
||||
permission::create(['name' => $data, 'group_name' => $first_group, 'desc' => $comment]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->info('Permission routes added successfully.');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Routing\Route;
|
||||
|
||||
class RouteCommentDescriptor
|
||||
{
|
||||
public static function register()
|
||||
{
|
||||
if (!Route::hasMacro('comment')) {
|
||||
Route::macro('comment', function ($params = null) {
|
||||
$this->_comment = $params;
|
||||
});
|
||||
}
|
||||
if (!Route::hasMacro('getComment')) {
|
||||
Route::macro('getComment', function () {
|
||||
if (!property_exists($this, '_comment'))
|
||||
return null;
|
||||
return $this->_comment;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,162 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admins\Users;
|
||||
|
||||
use App\Http\Controllers\Admins\Users\UserAccessController;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
class RoleController extends Controller
|
||||
{
|
||||
|
||||
private $uac;
|
||||
function __construct(UserAccessController $uac)
|
||||
{
|
||||
$this->uac = $uac;
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// call table user with pagination
|
||||
$datas = Role::latest()->paginate(10);
|
||||
|
||||
return view('pages.admins.roles.index', compact('datas'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$permissions = Permission::all()->groupBy('group_name');
|
||||
return view('pages.admins.roles.create', compact('permissions'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
// validation
|
||||
$rules = array(
|
||||
'name' => 'required',
|
||||
'email' => 'required|email',
|
||||
'password' => 'required|min:8'
|
||||
);
|
||||
$validator = Validator::make($request->all(), $rules);
|
||||
|
||||
// check validation
|
||||
if ($validator->fails()) {
|
||||
return Redirect::to('admin/roles/create')
|
||||
->withErrors($validator)
|
||||
->withInput($request->except('password'));
|
||||
} else {
|
||||
// create new account
|
||||
$user = Role::create([
|
||||
'name' => $request->name,
|
||||
'email' => $request->email,
|
||||
'password' => bcrypt($request->password),
|
||||
]);
|
||||
|
||||
// Create role for user
|
||||
$role = Role::findOrFail($request->role); // Pengunjung
|
||||
$user->assignRole($role);
|
||||
|
||||
// Create Session message
|
||||
Session::flash('roles-message', [
|
||||
'type' => 'success',
|
||||
'msg' => 'Anda berhasil menambahkan data!'
|
||||
]);
|
||||
|
||||
return Redirect::to('admin/roles');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit(string $id)
|
||||
{
|
||||
// get data from user
|
||||
$role = Role::findOrFail($id);
|
||||
$rolePermissions = $role->permissions()->pluck('name')->toArray();
|
||||
$permissions = Permission::get()->groupBy('group_name');
|
||||
|
||||
// call view pages
|
||||
return view('pages.admins.roles.edit', compact('role', 'permissions', 'rolePermissions'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, string $id)
|
||||
{
|
||||
// validation
|
||||
$rules = array(
|
||||
'name' => 'required|min:5',
|
||||
'permission' => 'required|min:8',
|
||||
);
|
||||
$validator = Validator::make($request->all(), $rules);
|
||||
|
||||
// process the login
|
||||
if ($validator->fails()) {
|
||||
return Redirect::to('admin/roles/edit/' . $id)
|
||||
->withErrors($validator)
|
||||
->withInput();
|
||||
} else {
|
||||
// create new account
|
||||
$role = Role::findOrFail($id);
|
||||
$role->update($request->only('name'));
|
||||
|
||||
$role->syncPermissions($request->get('permission'));
|
||||
// Create Session message
|
||||
Session::flash('roles-message', [
|
||||
'type' => 'success',
|
||||
'msg' => 'Anda berhasil mengubah data!'
|
||||
]);
|
||||
|
||||
return Redirect::to('admin/roles');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function refreshRoutes()
|
||||
{
|
||||
try {
|
||||
$result = $this->uac->generate();
|
||||
|
||||
if ($result['status' == 'success']) {
|
||||
return back()->with('success', $result['message']);
|
||||
} else {
|
||||
return back()->with('error', $result['message']);
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
//throw $th;
|
||||
}
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admins\Users;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use function Laravel\Prompts\error;
|
||||
|
||||
class UserAccessController extends Controller
|
||||
{
|
||||
public function generate()
|
||||
{
|
||||
try {
|
||||
|
||||
$routes = Route::getRoutes()->getRoutesByName();
|
||||
|
||||
foreach ($routes as $route) {
|
||||
if ($route->getName() != '' && count($route->getAction()['middleware']) >= 2) {
|
||||
$permission = Permission::where('name', $route->getName())->first();
|
||||
|
||||
$data = $route->getName();
|
||||
[$first_group] = explode('.', $data);
|
||||
$comment = $route->getComment();
|
||||
if (is_null($comment)) {
|
||||
$comment = Str::title(str_replace('.', ' ', $route->getName()));
|
||||
}
|
||||
if (is_null($permission)) {
|
||||
|
||||
permission::create(['name' => $data, 'group_name' => $first_group, 'desc' => $comment]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'status' => 'success',
|
||||
'message' => 'Permission routes refreshed'
|
||||
];
|
||||
} catch (\Throwable $th) {
|
||||
return [
|
||||
'status' => 'error',
|
||||
'message' => $th->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,178 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admins\Users;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// call table user with pagination
|
||||
$users = User::latest()->paginate(10);
|
||||
|
||||
return view('pages.admins.users.index', compact('users'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$roles = Role::latest()->get();
|
||||
|
||||
// call view users.create
|
||||
return view('pages.admins.users.create', compact('roles'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
// validation
|
||||
$rules = array(
|
||||
'name' => 'required',
|
||||
'email' => 'required|email',
|
||||
'password' => 'required|min:8'
|
||||
);
|
||||
$validator = Validator::make($request->all(), $rules);
|
||||
|
||||
// check validation
|
||||
if ($validator->fails()) {
|
||||
return Redirect::to('admin/users/create')
|
||||
->withErrors($validator)
|
||||
->withInput($request->except('password'));
|
||||
} else {
|
||||
// create new account
|
||||
$user = User::create([
|
||||
'name' => $request->name,
|
||||
'email' => $request->email,
|
||||
'password' => bcrypt($request->password),
|
||||
]);
|
||||
|
||||
// Create role for user
|
||||
$role = Role::findOrFail($request->role); // Pengunjung
|
||||
$user->assignRole($role);
|
||||
|
||||
// Create Session message
|
||||
Session::flash('users-message', [
|
||||
'type' => 'success',
|
||||
'msg' => 'Anda berhasil menambahkan data!'
|
||||
]);
|
||||
|
||||
return Redirect::to('admin/users');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit(string $id)
|
||||
{
|
||||
// get data from user
|
||||
$user = User::findOrFail($id);
|
||||
$roles = Role::latest()->get();
|
||||
|
||||
// call view pages
|
||||
return view('pages.admins.users.edit', compact('user', 'roles'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, string $id)
|
||||
{
|
||||
// validation
|
||||
$rules = array(
|
||||
'name' => 'required|min:5',
|
||||
'password' => 'required|min:8',
|
||||
);
|
||||
$validator = Validator::make($request->all(), $rules);
|
||||
|
||||
// process the login
|
||||
if ($validator->fails()) {
|
||||
return Redirect::to('admin/users/edit/' . $id)
|
||||
->withErrors($validator)
|
||||
->withInput($request->except('password'));
|
||||
} else {
|
||||
// create new account
|
||||
$user = User::findOrFail($id);
|
||||
if (!$user) {
|
||||
// Create Session message
|
||||
Session::flash('users-message', [
|
||||
'type' => 'warning',
|
||||
'msg' => 'Data pengguna tidak ditemukan!'
|
||||
]);
|
||||
|
||||
return Redirect::to('admin/users');
|
||||
}
|
||||
$user->update([
|
||||
'name' => $request->name,
|
||||
'password' => bcrypt($request->password),
|
||||
]);
|
||||
|
||||
// Update role for user
|
||||
$user->removeRole($user->roles[0]->name);
|
||||
$user->assignRole($request->role);
|
||||
|
||||
// Create Session message
|
||||
Session::flash('users-message', [
|
||||
'type' => 'success',
|
||||
'msg' => 'Anda berhasil mengubah data!'
|
||||
]);
|
||||
|
||||
return Redirect::to('admin/users');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(string $id)
|
||||
{
|
||||
// get data from role
|
||||
$role = Role::findOrFail($id);
|
||||
|
||||
// check role
|
||||
if (!$role) {
|
||||
// Create Session message
|
||||
Session::flash('roles-message', [
|
||||
'type' => 'warning',
|
||||
'msg' => 'Data pengguna tidak ditemukan!'
|
||||
]);
|
||||
|
||||
return Redirect::to('admin/roles');
|
||||
}
|
||||
|
||||
// delete role
|
||||
$role->delete();
|
||||
|
||||
// Create Session message
|
||||
Session::flash('roles-message', [
|
||||
'type' => 'success',
|
||||
'msg' => 'Anda berhasil menghapus data!'
|
||||
]);
|
||||
|
||||
return Redirect::to('admin/roles');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,142 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auths;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\User;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Spatie\Permission\Models\Role;
|
||||
use Symfony\Component\Console\Input\Input;
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function login()
|
||||
{
|
||||
return view('auth.login');
|
||||
}
|
||||
|
||||
public function auth_login(Request $request)
|
||||
{
|
||||
// validate
|
||||
// read more on validation at http://laravel.com/docs/validation
|
||||
$rules = array(
|
||||
'email' => 'required|email',
|
||||
'password' => 'required'
|
||||
);
|
||||
$validator = Validator::make($request->all(), $rules);
|
||||
|
||||
// process the login
|
||||
if ($validator->fails()) {
|
||||
return Redirect::to('login')
|
||||
->withErrors($validator)
|
||||
->withInput($request->except('password'));
|
||||
} else {
|
||||
try {
|
||||
$user = User::where('email', $request->email)->first();
|
||||
|
||||
if (Hash::check($request->password, $user->password)) {
|
||||
// Set Auth
|
||||
Auth::login($user);
|
||||
|
||||
// Create Session message
|
||||
Session::flash('login-message', [
|
||||
'type' => 'success',
|
||||
'msg' => 'Anda berhasil melakukan Login!'
|
||||
]);
|
||||
|
||||
// redirect
|
||||
return Redirect::to('/transaksi');
|
||||
} else {
|
||||
// Create Session message
|
||||
Session::flash('message', [
|
||||
'type' => 'warning',
|
||||
'msg' => 'Username atau password anda salah!'
|
||||
]);
|
||||
|
||||
// redirect
|
||||
return Redirect::to('login')->withInput($request->except('password'));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
// Create Session message
|
||||
Session::flash('message', [
|
||||
'type' => 'warning',
|
||||
'msg' => 'Username atau password anda salah!'
|
||||
]);
|
||||
|
||||
// redirect
|
||||
return Redirect::to('login')->withInput($request->except('password'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function login_proses(Request $request)
|
||||
{
|
||||
$validator = Validator::make(
|
||||
$request->all(),
|
||||
[
|
||||
'email' => ['required', 'string', 'email', 'exists:users,email'],
|
||||
'password' => ['required', 'string'],
|
||||
],
|
||||
['email.exists' => 'Akun anda belum terdaftar']
|
||||
);
|
||||
$errors = $validator->errors();
|
||||
$emailErrorMessage = $errors->first('email');
|
||||
|
||||
if ($validator->fails()) {
|
||||
// dd($validator->errors());
|
||||
Session::flash('message', [
|
||||
'type' => 'warning',
|
||||
'msg' => $emailErrorMessage
|
||||
]);
|
||||
return Redirect::to('login')->withInput($request->except('password'));
|
||||
}
|
||||
|
||||
try {
|
||||
if (Auth::attempt($validator->validated(), $request->has('remember_me') ? true : false)) {
|
||||
Session::flash('login-message', [
|
||||
'type' => 'success',
|
||||
'msg' => 'Anda berhasil melakukan Login!'
|
||||
]);
|
||||
|
||||
return redirect()->intended('/transaksi');
|
||||
}
|
||||
|
||||
// Create Session message
|
||||
Session::flash('message', [
|
||||
'type' => 'warning',
|
||||
'msg' => 'Username atau password anda salah!'
|
||||
]);
|
||||
|
||||
// redirect
|
||||
return Redirect::to('login')->withInput($request->except('password'));
|
||||
} catch (\Exception $e) {
|
||||
// Create Session message
|
||||
Session::flash('message', [
|
||||
'type' => 'warning',
|
||||
'msg' => 'Terjadi Kesalahan!'
|
||||
]);
|
||||
|
||||
// redirect
|
||||
return Redirect::to('login')->withInput($request->except('password'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Logout and back to form login
|
||||
*/
|
||||
public function logout()
|
||||
{
|
||||
// logout and clear data Auth
|
||||
Auth::logout();
|
||||
return Redirect::to('login');
|
||||
}
|
||||
}
|
|
@ -40,7 +40,7 @@ class Kernel extends HttpKernel
|
|||
|
||||
'api' => [
|
||||
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
|
||||
\Illuminate\Routing\Middleware\ThrottleRequests::class.':api',
|
||||
\Illuminate\Routing\Middleware\ThrottleRequests::class . ':api',
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
];
|
||||
|
@ -64,5 +64,8 @@ class Kernel extends HttpKernel
|
|||
'signed' => \App\Http\Middleware\ValidateSignature::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||
'role' => \Spatie\Permission\Middleware\RoleMiddleware::class,
|
||||
'permission' => \Spatie\Permission\Middleware\PermissionMiddleware::class,
|
||||
'role_or_permission' => \Spatie\Permission\Middleware\RoleOrPermissionMiddleware::class,
|
||||
];
|
||||
}
|
||||
|
|
|
@ -7,10 +7,11 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use HasApiTokens, HasFactory, Notifiable;
|
||||
use HasApiTokens, HasFactory, Notifiable, HasRoles;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use App\Helpers\RouteCommentDescriptor;
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
|
@ -11,7 +13,7 @@ class AppServiceProvider extends ServiceProvider
|
|||
*/
|
||||
public function register(): void
|
||||
{
|
||||
//
|
||||
RouteCommentDescriptor::register();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,6 +21,9 @@ class AppServiceProvider extends ServiceProvider
|
|||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
//
|
||||
// add fucntion on blade
|
||||
Blade::if('role', function ($name) {
|
||||
return auth()->check() && auth()->user()->hasRole($name);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ class RouteServiceProvider extends ServiceProvider
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
public const HOME = '/home';
|
||||
public const HOME = '/transaksi';
|
||||
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, and other route configuration.
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
"laravel/framework": "^10.10",
|
||||
"laravel/sanctum": "^3.3",
|
||||
"laravel/tinker": "^2.8",
|
||||
"yajra/laravel-datatables": "^10.1",
|
||||
"spatie/laravel-permission": "^5.9",
|
||||
"realrashid/sweet-alert": "^6.0"
|
||||
"realrashid/sweet-alert": "^6.0",
|
||||
"spatie/laravel-permission": "^6.3",
|
||||
"yajra/laravel-datatables": "^10.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"fakerphp/faker": "^1.9.1",
|
||||
|
@ -38,7 +38,8 @@
|
|||
"app/Helpers/ResponseFormatter.php",
|
||||
"app/Helpers/RandomString.php",
|
||||
"app/Helpers/RupiahConverter.php",
|
||||
"app/Helpers/RupiahRounding.php"
|
||||
"app/Helpers/RupiahRounding.php",
|
||||
"app/Helpers/RouteCommandDescriptor.php"
|
||||
]
|
||||
},
|
||||
"autoload-dev": {
|
||||
|
|
|
@ -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": "78bf9d94ab2c24700fe6d8f867021e87",
|
||||
"content-hash": "c2a087156cf7cdb5fbd03918562d593c",
|
||||
"packages": [
|
||||
{
|
||||
"name": "brick/math",
|
||||
|
@ -3867,35 +3867,35 @@
|
|||
},
|
||||
{
|
||||
"name": "spatie/laravel-permission",
|
||||
"version": "5.11.1",
|
||||
"version": "6.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/spatie/laravel-permission.git",
|
||||
"reference": "7090824cca57e693b880ce3aaf7ef78362e28bbd"
|
||||
"reference": "4d119986c862ac0168b77338c85d8236bb559a88"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/spatie/laravel-permission/zipball/7090824cca57e693b880ce3aaf7ef78362e28bbd",
|
||||
"reference": "7090824cca57e693b880ce3aaf7ef78362e28bbd",
|
||||
"url": "https://api.github.com/repos/spatie/laravel-permission/zipball/4d119986c862ac0168b77338c85d8236bb559a88",
|
||||
"reference": "4d119986c862ac0168b77338c85d8236bb559a88",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/auth": "^7.0|^8.0|^9.0|^10.0",
|
||||
"illuminate/container": "^7.0|^8.0|^9.0|^10.0",
|
||||
"illuminate/contracts": "^7.0|^8.0|^9.0|^10.0",
|
||||
"illuminate/database": "^7.0|^8.0|^9.0|^10.0",
|
||||
"php": "^7.3|^8.0"
|
||||
"illuminate/auth": "^8.12|^9.0|^10.0|^11.0",
|
||||
"illuminate/container": "^8.12|^9.0|^10.0|^11.0",
|
||||
"illuminate/contracts": "^8.12|^9.0|^10.0|^11.0",
|
||||
"illuminate/database": "^8.12|^9.0|^10.0|^11.0",
|
||||
"php": "^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"orchestra/testbench": "^5.0|^6.0|^7.0|^8.0",
|
||||
"phpunit/phpunit": "^9.4",
|
||||
"predis/predis": "^1.1"
|
||||
"laravel/passport": "^11.0",
|
||||
"orchestra/testbench": "^6.23|^7.0|^8.0|^9.0",
|
||||
"phpunit/phpunit": "^9.4|^10.1"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-main": "5.x-dev",
|
||||
"dev-master": "5.x-dev"
|
||||
"dev-main": "6.x-dev",
|
||||
"dev-master": "6.x-dev"
|
||||
},
|
||||
"laravel": {
|
||||
"providers": [
|
||||
|
@ -3923,7 +3923,7 @@
|
|||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "Permission handling for Laravel 6.0 and up",
|
||||
"description": "Permission handling for Laravel 8.0 and up",
|
||||
"homepage": "https://github.com/spatie/laravel-permission",
|
||||
"keywords": [
|
||||
"acl",
|
||||
|
@ -3937,7 +3937,7 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/spatie/laravel-permission/issues",
|
||||
"source": "https://github.com/spatie/laravel-permission/tree/5.11.1"
|
||||
"source": "https://github.com/spatie/laravel-permission/tree/6.3.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
@ -3945,7 +3945,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2023-10-25T05:12:01+00:00"
|
||||
"time": "2023-12-24T06:58:02+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/console",
|
||||
|
|
|
@ -168,6 +168,7 @@ return [
|
|||
// App\Providers\BroadcastServiceProvider::class,
|
||||
App\Providers\EventServiceProvider::class,
|
||||
App\Providers\RouteServiceProvider::class,
|
||||
Spatie\Permission\PermissionServiceProvider::class,
|
||||
])->toArray(),
|
||||
|
||||
/*
|
||||
|
|
|
@ -0,0 +1,161 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
'models' => [
|
||||
|
||||
/*
|
||||
* When using the "HasPermissions" trait from this package, we need to know which
|
||||
* Eloquent model should be used to retrieve your permissions. Of course, it
|
||||
* is often just the "Permission" model but you may use whatever you like.
|
||||
*
|
||||
* The model you want to use as a Permission model needs to implement the
|
||||
* `Spatie\Permission\Contracts\Permission` contract.
|
||||
*/
|
||||
|
||||
'permission' => Spatie\Permission\Models\Permission::class,
|
||||
|
||||
/*
|
||||
* When using the "HasRoles" trait from this package, we need to know which
|
||||
* Eloquent model should be used to retrieve your roles. Of course, it
|
||||
* is often just the "Role" model but you may use whatever you like.
|
||||
*
|
||||
* The model you want to use as a Role model needs to implement the
|
||||
* `Spatie\Permission\Contracts\Role` contract.
|
||||
*/
|
||||
|
||||
'role' => Spatie\Permission\Models\Role::class,
|
||||
|
||||
],
|
||||
|
||||
'table_names' => [
|
||||
|
||||
/*
|
||||
* When using the "HasRoles" trait from this package, we need to know which
|
||||
* table should be used to retrieve your roles. We have chosen a basic
|
||||
* default value but you may easily change it to any table you like.
|
||||
*/
|
||||
|
||||
'roles' => 'roles',
|
||||
|
||||
/*
|
||||
* When using the "HasPermissions" trait from this package, we need to know which
|
||||
* table should be used to retrieve your permissions. We have chosen a basic
|
||||
* default value but you may easily change it to any table you like.
|
||||
*/
|
||||
|
||||
'permissions' => 'permissions',
|
||||
|
||||
/*
|
||||
* When using the "HasPermissions" trait from this package, we need to know which
|
||||
* table should be used to retrieve your models permissions. We have chosen a
|
||||
* basic default value but you may easily change it to any table you like.
|
||||
*/
|
||||
|
||||
'model_has_permissions' => 'model_has_permissions',
|
||||
|
||||
/*
|
||||
* When using the "HasRoles" trait from this package, we need to know which
|
||||
* table should be used to retrieve your models roles. We have chosen a
|
||||
* basic default value but you may easily change it to any table you like.
|
||||
*/
|
||||
|
||||
'model_has_roles' => 'model_has_roles',
|
||||
|
||||
/*
|
||||
* When using the "HasRoles" trait from this package, we need to know which
|
||||
* table should be used to retrieve your roles permissions. We have chosen a
|
||||
* basic default value but you may easily change it to any table you like.
|
||||
*/
|
||||
|
||||
'role_has_permissions' => 'role_has_permissions',
|
||||
],
|
||||
|
||||
'column_names' => [
|
||||
/*
|
||||
* Change this if you want to name the related pivots other than defaults
|
||||
*/
|
||||
'role_pivot_key' => null, //default 'role_id',
|
||||
'permission_pivot_key' => null, //default 'permission_id',
|
||||
|
||||
/*
|
||||
* Change this if you want to name the related model primary key other than
|
||||
* `model_id`.
|
||||
*
|
||||
* For example, this would be nice if your primary keys are all UUIDs. In
|
||||
* that case, name this `model_uuid`.
|
||||
*/
|
||||
|
||||
'model_morph_key' => 'model_id',
|
||||
|
||||
/*
|
||||
* Change this if you want to use the teams feature and your related model's
|
||||
* foreign key is other than `team_id`.
|
||||
*/
|
||||
|
||||
'team_foreign_key' => 'team_id',
|
||||
],
|
||||
|
||||
/*
|
||||
* When set to true, the method for checking permissions will be registered on the gate.
|
||||
* Set this to false, if you want to implement custom logic for checking permissions.
|
||||
*/
|
||||
|
||||
'register_permission_check_method' => true,
|
||||
|
||||
/*
|
||||
* When set to true the package implements teams using the 'team_foreign_key'. If you want
|
||||
* the migrations to register the 'team_foreign_key', you must set this to true
|
||||
* before doing the migration. If you already did the migration then you must make a new
|
||||
* migration to also add 'team_foreign_key' to 'roles', 'model_has_roles', and
|
||||
* 'model_has_permissions'(view the latest version of package's migration file)
|
||||
*/
|
||||
|
||||
'teams' => false,
|
||||
|
||||
/*
|
||||
* When set to true, the required permission names are added to the exception
|
||||
* message. This could be considered an information leak in some contexts, so
|
||||
* the default setting is false here for optimum safety.
|
||||
*/
|
||||
|
||||
'display_permission_in_exception' => false,
|
||||
|
||||
/*
|
||||
* When set to true, the required role names are added to the exception
|
||||
* message. This could be considered an information leak in some contexts, so
|
||||
* the default setting is false here for optimum safety.
|
||||
*/
|
||||
|
||||
'display_role_in_exception' => false,
|
||||
|
||||
/*
|
||||
* By default wildcard permission lookups are disabled.
|
||||
*/
|
||||
|
||||
'enable_wildcard_permission' => false,
|
||||
|
||||
'cache' => [
|
||||
|
||||
/*
|
||||
* By default all permissions are cached for 24 hours to speed up performance.
|
||||
* When permissions or roles are updated the cache is flushed automatically.
|
||||
*/
|
||||
|
||||
'expiration_time' => \DateInterval::createFromDateString('24 hours'),
|
||||
|
||||
/*
|
||||
* The cache key used to store all permissions.
|
||||
*/
|
||||
|
||||
'key' => 'spatie.permission.cache',
|
||||
|
||||
/*
|
||||
* You may optionally indicate a specific cache driver to use for permission and
|
||||
* role caching using any of the `store` drivers listed in the cache.php config
|
||||
* file. Using 'default' here means to use the `default` set in cache.php.
|
||||
*/
|
||||
|
||||
'store' => 'default',
|
||||
],
|
||||
];
|
|
@ -0,0 +1,138 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$teams = config('permission.teams');
|
||||
$tableNames = config('permission.table_names');
|
||||
$columnNames = config('permission.column_names');
|
||||
$pivotRole = $columnNames['role_pivot_key'] ?? 'role_id';
|
||||
$pivotPermission = $columnNames['permission_pivot_key'] ?? 'permission_id';
|
||||
|
||||
if (empty($tableNames)) {
|
||||
throw new \Exception('Error: config/permission.php not loaded. Run [php artisan config:clear] and try again.');
|
||||
}
|
||||
if ($teams && empty($columnNames['team_foreign_key'] ?? null)) {
|
||||
throw new \Exception('Error: team_foreign_key on config/permission.php not loaded. Run [php artisan config:clear] and try again.');
|
||||
}
|
||||
|
||||
Schema::create($tableNames['permissions'], function (Blueprint $table) {
|
||||
$table->bigIncrements('id'); // permission id
|
||||
$table->string('name'); // For MySQL 8.0 use string('name', 125);
|
||||
$table->string('guard_name'); // For MySQL 8.0 use string('guard_name', 125);
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['name', 'guard_name']);
|
||||
});
|
||||
|
||||
Schema::create($tableNames['roles'], function (Blueprint $table) use ($teams, $columnNames) {
|
||||
$table->bigIncrements('id'); // role id
|
||||
if ($teams || config('permission.testing')) { // permission.testing is a fix for sqlite testing
|
||||
$table->unsignedBigInteger($columnNames['team_foreign_key'])->nullable();
|
||||
$table->index($columnNames['team_foreign_key'], 'roles_team_foreign_key_index');
|
||||
}
|
||||
$table->string('name'); // For MySQL 8.0 use string('name', 125);
|
||||
$table->string('guard_name'); // For MySQL 8.0 use string('guard_name', 125);
|
||||
$table->timestamps();
|
||||
if ($teams || config('permission.testing')) {
|
||||
$table->unique([$columnNames['team_foreign_key'], 'name', 'guard_name']);
|
||||
} else {
|
||||
$table->unique(['name', 'guard_name']);
|
||||
}
|
||||
});
|
||||
|
||||
Schema::create($tableNames['model_has_permissions'], function (Blueprint $table) use ($tableNames, $columnNames, $pivotPermission, $teams) {
|
||||
$table->unsignedBigInteger($pivotPermission);
|
||||
|
||||
$table->string('model_type');
|
||||
$table->unsignedBigInteger($columnNames['model_morph_key']);
|
||||
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_model_id_model_type_index');
|
||||
|
||||
$table->foreign($pivotPermission)
|
||||
->references('id') // permission id
|
||||
->on($tableNames['permissions'])
|
||||
->onDelete('cascade');
|
||||
if ($teams) {
|
||||
$table->unsignedBigInteger($columnNames['team_foreign_key']);
|
||||
$table->index($columnNames['team_foreign_key'], 'model_has_permissions_team_foreign_key_index');
|
||||
|
||||
$table->primary([$columnNames['team_foreign_key'], $pivotPermission, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_permissions_permission_model_type_primary');
|
||||
} else {
|
||||
$table->primary([$pivotPermission, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_permissions_permission_model_type_primary');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ($tableNames, $columnNames, $pivotRole, $teams) {
|
||||
$table->unsignedBigInteger($pivotRole);
|
||||
|
||||
$table->string('model_type');
|
||||
$table->unsignedBigInteger($columnNames['model_morph_key']);
|
||||
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_roles_model_id_model_type_index');
|
||||
|
||||
$table->foreign($pivotRole)
|
||||
->references('id') // role id
|
||||
->on($tableNames['roles'])
|
||||
->onDelete('cascade');
|
||||
if ($teams) {
|
||||
$table->unsignedBigInteger($columnNames['team_foreign_key']);
|
||||
$table->index($columnNames['team_foreign_key'], 'model_has_roles_team_foreign_key_index');
|
||||
|
||||
$table->primary([$columnNames['team_foreign_key'], $pivotRole, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_roles_role_model_type_primary');
|
||||
} else {
|
||||
$table->primary([$pivotRole, $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_roles_role_model_type_primary');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::create($tableNames['role_has_permissions'], function (Blueprint $table) use ($tableNames, $pivotRole, $pivotPermission) {
|
||||
$table->unsignedBigInteger($pivotPermission);
|
||||
$table->unsignedBigInteger($pivotRole);
|
||||
|
||||
$table->foreign($pivotPermission)
|
||||
->references('id') // permission id
|
||||
->on($tableNames['permissions'])
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->foreign($pivotRole)
|
||||
->references('id') // role id
|
||||
->on($tableNames['roles'])
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->primary([$pivotPermission, $pivotRole], 'role_has_permissions_permission_id_role_id_primary');
|
||||
});
|
||||
|
||||
app('cache')
|
||||
->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null)
|
||||
->forget(config('permission.cache.key'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
$tableNames = config('permission.table_names');
|
||||
|
||||
if (empty($tableNames)) {
|
||||
throw new \Exception('Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding, or drop the tables manually.');
|
||||
}
|
||||
|
||||
Schema::drop($tableNames['role_has_permissions']);
|
||||
Schema::drop($tableNames['model_has_roles']);
|
||||
Schema::drop($tableNames['model_has_permissions']);
|
||||
Schema::drop($tableNames['roles']);
|
||||
Schema::drop($tableNames['permissions']);
|
||||
}
|
||||
};
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class AddRoles extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$data_roles = [
|
||||
[
|
||||
'name' => 'Admin',
|
||||
'guard_name' => 'web',
|
||||
'created_at' => Carbon::now()->toDateTimeString(),
|
||||
'updated_at' => Carbon::now()->toDateTimeString()
|
||||
],
|
||||
[
|
||||
'name' => 'Manager',
|
||||
'guard_name' => 'web',
|
||||
'created_at' => Carbon::now()->toDateTimeString(),
|
||||
'updated_at' => Carbon::now()->toDateTimeString()
|
||||
],
|
||||
[
|
||||
'name' => 'Kasir',
|
||||
'guard_name' => 'web',
|
||||
'created_at' => Carbon::now()->toDateTimeString(),
|
||||
'updated_at' => Carbon::now()->toDateTimeString()
|
||||
],
|
||||
[
|
||||
'name' => 'Karyawan',
|
||||
'guard_name' => 'web',
|
||||
'created_at' => Carbon::now()->toDateTimeString(),
|
||||
'updated_at' => Carbon::now()->toDateTimeString()
|
||||
],
|
||||
];
|
||||
|
||||
DB::table('roles')->insert($data_roles);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
class AddUsers extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// Add Users
|
||||
$data = User::create([
|
||||
'name' => 'Admin',
|
||||
'email' => 'admin@mail.id',
|
||||
'password' => bcrypt('password')
|
||||
]);
|
||||
|
||||
$permissions = Permission::pluck('id', 'id')->all();
|
||||
$role = Role::findById(1);
|
||||
$role->givePermissionTo($permissions);
|
||||
$role->syncPermissions($permissions);
|
||||
$data->assignRole([$role->id]);
|
||||
}
|
||||
}
|
|
@ -18,7 +18,8 @@ class DatabaseSeeder extends Seeder
|
|||
KelompokKategoriSeeder::class,
|
||||
ProdukSeeder::class,
|
||||
KelompokKategoriPivotSeeder::class,
|
||||
UserSeeder::class,
|
||||
|
||||
// UserSeeder::class,
|
||||
];
|
||||
|
||||
foreach ($classes as $class) {
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
class KasirSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$user = [
|
||||
[
|
||||
'name' => 'kasir',
|
||||
'email' => 'kasir@mail.com',
|
||||
'email_verified_at' => now(),
|
||||
'password' => bcrypt('kasirsaja')
|
||||
],
|
||||
];
|
||||
|
||||
$role = Role::create(['name' => 'Kasir']);
|
||||
|
||||
$permissions = Permission::pluck('id', 'id')->all();
|
||||
$role->givePermissionTo($permissions);
|
||||
$role->syncPermissions($permissions);
|
||||
|
||||
foreach ($user as $key => $value) {
|
||||
$data = User::create($value);
|
||||
$data->assignRole([$role->id]);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class PermissionSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$classes = [
|
||||
// UserSeeder::class,
|
||||
// KasirSeeder::class,
|
||||
// AddRoles::class,
|
||||
RoleSeeder::class,
|
||||
];
|
||||
foreach ($classes as $class) $this->call($class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
class RoleSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$role = Role::create(['name' => 'Admin']);
|
||||
|
||||
$permissions = Permission::pluck('id', 'id')->all();
|
||||
$role->givePermissionTo($permissions);
|
||||
$role->syncPermissions($permissions);
|
||||
|
||||
$user = User::find(1);
|
||||
|
||||
$user->assignRole([$role->id]);
|
||||
|
||||
$role = Role::create(['name' => 'Kasir']);
|
||||
|
||||
$permissions = Permission::pluck('id', 'id')->all();
|
||||
$role->givePermissionTo($permissions);
|
||||
$role->syncPermissions($permissions);
|
||||
|
||||
$user = User::find(2);
|
||||
|
||||
$user->assignRole([$role->id]);
|
||||
}
|
||||
}
|
|
@ -2,8 +2,11 @@
|
|||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
class UserSeeder extends Seeder
|
||||
{
|
||||
|
@ -12,21 +15,24 @@ class UserSeeder extends Seeder
|
|||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$data = [
|
||||
$user = [
|
||||
[
|
||||
'name' => 'Admin',
|
||||
'email' => 'Admin@mail.com',
|
||||
'password' => bcrypt('adminsaja'),
|
||||
],
|
||||
[
|
||||
'name' => 'Kasir',
|
||||
'email' => 'Kasir@mail.com',
|
||||
'password' => bcrypt('kasirsaja'),
|
||||
'name' => 'admin',
|
||||
'email' => 'admin@mail.id',
|
||||
'email_verified_at' => now(),
|
||||
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
\App\Models\User::create($value);
|
||||
$role = Role::create(['name' => 'Admin']);
|
||||
|
||||
$permissions = Permission::pluck('id', 'id')->all();
|
||||
$role->givePermissionTo($permissions);
|
||||
$role->syncPermissions($permissions);
|
||||
|
||||
foreach ($user as $key => $value) {
|
||||
$data = User::create($value);
|
||||
$data->assignRole([$role->id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 376 KiB |
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 157 KiB |
|
@ -0,0 +1,126 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Sepiring Telur Log in</title>
|
||||
|
||||
<!-- Google Font: Source Sans Pro -->
|
||||
<link rel="stylesheet"
|
||||
href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
|
||||
<!-- Font Awesome -->
|
||||
<link rel="stylesheet" href="{{ asset('assets/plugins/fontawesome-free/css/all.min.css') }}">
|
||||
<!-- icheck bootstrap -->
|
||||
<link rel="stylesheet" href="{{ asset('assets/plugins/icheck-bootstrap/icheck-bootstrap.min.css') }}">
|
||||
<!-- Theme style -->
|
||||
<link rel="stylesheet" href="{{ asset('assets/dist/css/adminlte.min.css') }}">
|
||||
</head>
|
||||
|
||||
<body class="hold-transition login-page">
|
||||
<div class="login-box">
|
||||
<!-- /.login-logo -->
|
||||
<div class="card card-outline card-warning">
|
||||
<div class="card-header text-center">
|
||||
<a href="{{ route('login') }}" class="h1"><b>Log</b> IN</a>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="text-center">
|
||||
<img src="{{ asset('assets/images/logo bulat Sepiring Telur Keriting lengkap-04 1.svg') }}"
|
||||
width="200px" class="img-fluid pad" alt="Sepiring Telur Keriting" style="">
|
||||
</div>
|
||||
<h3 class="login-box-msg">Sepiring Telur Keriting</h3>
|
||||
@if (Session::has('message'))
|
||||
<div class="alert alert-{{ Session::get('message')['type'] }}">
|
||||
{{ Session::get('message')['msg'] }}</div>
|
||||
@endif
|
||||
<form class="needs-validation" method="post" action="{{ route('login.process') }}">
|
||||
@csrf
|
||||
<div class="input-group mb-3">
|
||||
<input type="email" class="form-control" placeholder="Email" name="email">
|
||||
<div class="input-group-append">
|
||||
<div class="input-group-text">
|
||||
<span class="fas fa-envelope"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="input-group mb-3">
|
||||
<input type="password" class="form-control" placeholder="Password" name="password">
|
||||
<div class="input-group-append">
|
||||
<button type="button" class="btn btn-default" id="showPassword">
|
||||
<span class="fas fa-lock"></span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8">
|
||||
<div class="icheck-primary">
|
||||
<input type="checkbox" id="remember">
|
||||
<label for="remember">
|
||||
Remember Me
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
<div class="col-4">
|
||||
<button type="submit" class="btn btn-warning btn-block">Sign In</button>
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<!-- /.card-body -->
|
||||
</div>
|
||||
<!-- /.card -->
|
||||
</div>
|
||||
<!-- /.login-box -->
|
||||
|
||||
<link rel="stylesheet" href="{{ asset('assets/plugins/toastr/toastr.min.css') }}">
|
||||
|
||||
<!-- jQuery -->
|
||||
<script src="{{ asset('assets/plugins/jquery/jquery.min.js') }}"></script>
|
||||
<!-- Bootstrap 4 -->
|
||||
<script src="{{ asset('assets/plugins/bootstrap/js/bootstrap.bundle.min.js') }}"></script>
|
||||
<!-- AdminLTE App -->
|
||||
<script src="{{ asset('assets/dist/js/adminlte.min.js') }}"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('#showPassword').click(function() {
|
||||
console.log('clicked');
|
||||
if ($(this).hasClass('btn-default')) {
|
||||
$(this).removeClass('btn-default');
|
||||
$(this).addClass('btn-primary');
|
||||
$(this).html('<span class="fas fa-unlock"></span>');
|
||||
$('input[type="password"]').attr('type', 'text');
|
||||
} else {
|
||||
$(this).removeClass('btn-primary');
|
||||
$(this).addClass('btn-default');
|
||||
$(this).html('<span class="fas fa-lock"></span>');
|
||||
$('input[type="text"]').attr('type', 'password');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function showAlert(params) {
|
||||
|
||||
var result = JSON.parse(params);
|
||||
if (result.status == 'error') {
|
||||
toastr.error(result.message, 'Error', {
|
||||
timeOut: 2000
|
||||
});
|
||||
} else if (result.status == 'warning') {
|
||||
toastr.warning(result.message, 'Warning', {
|
||||
timeOut: 2000
|
||||
});
|
||||
} else if (result.status == 'success') {
|
||||
toastr.success(result.message, 'Success', {
|
||||
timeOut: 2000
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -91,17 +91,14 @@
|
|||
<i class="fas fa-expand"></i>
|
||||
</a>
|
||||
</li>
|
||||
{{-- <li class="nav-item">
|
||||
<a class="nav-link" id="full-screen" data-widget="control-sidebar" data-slide="true"
|
||||
href="javascript:void(0)" role="button">
|
||||
<i class="fa fa-arrows-rotate"></i>
|
||||
</a>
|
||||
</li> --}}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" id="logout" data-widget="control-sidebar" data-slide="true" href="#"
|
||||
role="button">
|
||||
<li class="nav-item dropdown">
|
||||
<a id="dropdownSubMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"
|
||||
class="nav-link" href="#">
|
||||
<i class="fas fa-user"></i>
|
||||
</a>
|
||||
<ul aria-labelledby="dropdownSubMenu1" class="dropdown-menu border-0 shadow">
|
||||
<li><a href="{{ route('logout') }}" class="dropdown-item">Logout</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
<?php
|
||||
|
||||
use App\Http\Controllers\Auths\AuthController;
|
||||
use App\Http\Controllers\Kasir\History;
|
||||
use App\Http\Controllers\Kasir\Menu;
|
||||
use App\Http\Controllers\Kasir\Transaksi;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
/*
|
||||
|
@ -16,28 +18,39 @@ use Illuminate\Support\Facades\Route;
|
|||
|
|
||||
*/
|
||||
|
||||
Route::get('/', [Transaksi::class, 'index'])->name('transaksi.index');
|
||||
// Authentication
|
||||
Route::group(['middleware' => 'guest'], function () {
|
||||
Route::get("/", fn () => redirect()->to('/login'))->name("default"); // login
|
||||
|
||||
Route::group(['prefix' => 'transaksi'], function () {
|
||||
Route::get('/', [Transaksi::class, 'index'])->name('transaksi.index');
|
||||
Route::post('/store', [Transaksi::class, 'store'])->name('transaksi.store');
|
||||
Route::get('/print/{id}', [Transaksi::class, 'print'])->name('transaksi.print');
|
||||
Route::get('/detail/{id}', [Transaksi::class, 'detail'])->name('transaksi.detail');
|
||||
Route::post('/cari-paket', [Transaksi::class, 'selectPaket'])->name('transaksi.cari-paket');
|
||||
Route::get('/getCetakTigaKali', [Transaksi::class, 'getCetakTigaKali'])->name('transaksi.getCetakTigaKali');
|
||||
Route::get('/printDapurTigaKali/{id}', [Transaksi::class, 'printDapurTigaKali'])->name('transaksi.printDapurTigaKali');
|
||||
Route::get('/printDapurDuaKali/{id}', [Transaksi::class, 'printDapurDuaKali'])->name('transaksi.printDapurDuaKali');
|
||||
Route::get('/printDapurSatuKali/{id}', [Transaksi::class, 'printDapurSatuKali'])->name('transaksi.printDapurSatuKali');
|
||||
// Login
|
||||
Route::get('login', [AuthController::class, 'login'])->name('login')->comment("Halaman Login");
|
||||
Route::post('login', [AuthController::class, 'login_proses'])->name('login.process')->comment("Login Action");
|
||||
});
|
||||
|
||||
Route::group(['prefix' => 'history'], function () {
|
||||
Route::get('/', [History::class, 'index'])->name('history.index');
|
||||
Route::get('/getDataHistory', [History::class, 'getDataHistory'])->name('history.getDataHistory');
|
||||
Route::get('/print/{id}', [History::class, 'print'])->name('history.print');
|
||||
Route::post('/getDataDetailHistory', [History::class, 'getDataDetailHistory'])->name('history.getDataDetailHistory');
|
||||
});
|
||||
Route::group(['middleware' => ['auth', 'role:Admin|Manager|Kasir|Karyawan']], function () {
|
||||
// Logout
|
||||
Route::get('logout', [AuthController::class, 'logout'])->name('logout')->comment("Logout Action");
|
||||
|
||||
Route::group(['prefix' => 'menu'], function () {
|
||||
Route::get('/', [Menu::class, 'index'])->name('menu.index');
|
||||
Route::get('/getDataMenu', [Menu::class, 'getDataMenu'])->name('menu.getDataMenu');
|
||||
Route::group(['prefix' => 'transaksi'], function () {
|
||||
Route::get('/', [Transaksi::class, 'index'])->name('transaksi.index')->comment("Halaman Transaksi");
|
||||
Route::post('/store', [Transaksi::class, 'store'])->name('transaksi.store')->comment("Proses Transaksi");
|
||||
Route::get('/print/{id}', [Transaksi::class, 'print'])->name('transaksi.print')->comment("Print Transaksi");
|
||||
Route::get('/detail/{id}', [Transaksi::class, 'detail'])->name('transaksi.detail')->comment("Detail Transaksi");
|
||||
Route::post('/cari-paket', [Transaksi::class, 'selectPaket'])->name('transaksi.cari-paket')->comment("Cari Paket Spesial");
|
||||
Route::get('/getCetakTigaKali', [Transaksi::class, 'getCetakTigaKali'])->name('transaksi.getCetakTigaKali')->comment("Modal Cetak");
|
||||
Route::get('/printDapurTigaKali/{id}', [Transaksi::class, 'printDapurTigaKali'])->name('transaksi.printDapurTigaKali')->comment("Print Dapur Tiga Kali");
|
||||
Route::get('/printDapurDuaKali/{id}', [Transaksi::class, 'printDapurDuaKali'])->name('transaksi.printDapurDuaKali')->comment("Print Dapur Dua Kali");
|
||||
Route::get('/printDapurSatuKali/{id}', [Transaksi::class, 'printDapurSatuKali'])->name('transaksi.printDapurSatuKali')->comment("Print Dapur Satu Kali");
|
||||
});
|
||||
|
||||
Route::group(['prefix' => 'history'], function () {
|
||||
Route::get('/', [History::class, 'index'])->name('history.index')->comment("Halaman Riwayat Transaksi");
|
||||
Route::get('/getDataHistory', [History::class, 'getDataHistory'])->name('history.getDataHistory')->comment("Ambil data Riwayat Transaksi");
|
||||
Route::get('/print/{id}', [History::class, 'print'])->name('history.print')->comment("Print Riwayat Transaksi");
|
||||
Route::post('/getDataDetailHistory', [History::class, 'getDataDetailHistory'])->name('history.getDataDetailHistory')->comment("Ambil data Detail Riwayat Transaksi");
|
||||
});
|
||||
Route::group(['prefix' => 'menu'], function () {
|
||||
Route::get('/', [Menu::class, 'index'])->name('menu.index')->comment("Halaman Menu");
|
||||
Route::get('/getDataMenu', [Menu::class, 'getDataMenu'])->name('menu.getDataMenu')->comment("Ambil data Menu");
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue