@ -0,0 +1,54 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth; |
||||||
|
|
||||||
|
use App\Http\Controllers\Controller; |
||||||
|
use App\Http\Requests\Auth\LoginRequest; |
||||||
|
use App\Providers\RouteServiceProvider; |
||||||
|
use Illuminate\Http\Request; |
||||||
|
use Illuminate\Support\Facades\Auth; |
||||||
|
|
||||||
|
class AuthenticatedSessionController extends Controller |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Display the login view. |
||||||
|
* |
||||||
|
* @return \Illuminate\View\View |
||||||
|
*/ |
||||||
|
public function create() |
||||||
|
{ |
||||||
|
return view('auth.login'); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Handle an incoming authentication request. |
||||||
|
* |
||||||
|
* @param \App\Http\Requests\Auth\LoginRequest $request |
||||||
|
* @return \Illuminate\Http\RedirectResponse |
||||||
|
*/ |
||||||
|
public function store(LoginRequest $request) |
||||||
|
{ |
||||||
|
$request->authenticate(); |
||||||
|
|
||||||
|
$request->session()->regenerate(); |
||||||
|
|
||||||
|
return redirect()->intended(RouteServiceProvider::HOME); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Destroy an authenticated session. |
||||||
|
* |
||||||
|
* @param \Illuminate\Http\Request $request |
||||||
|
* @return \Illuminate\Http\RedirectResponse |
||||||
|
*/ |
||||||
|
public function destroy(Request $request) |
||||||
|
{ |
||||||
|
Auth::guard('web')->logout(); |
||||||
|
|
||||||
|
$request->session()->invalidate(); |
||||||
|
|
||||||
|
$request->session()->regenerateToken(); |
||||||
|
|
||||||
|
return redirect('/'); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,44 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth; |
||||||
|
|
||||||
|
use App\Http\Controllers\Controller; |
||||||
|
use App\Providers\RouteServiceProvider; |
||||||
|
use Illuminate\Http\Request; |
||||||
|
use Illuminate\Support\Facades\Auth; |
||||||
|
use Illuminate\Validation\ValidationException; |
||||||
|
|
||||||
|
class ConfirmablePasswordController extends Controller |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Show the confirm password view. |
||||||
|
* |
||||||
|
* @return \Illuminate\View\View |
||||||
|
*/ |
||||||
|
public function show() |
||||||
|
{ |
||||||
|
return view('auth.confirm-password'); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Confirm the user's password. |
||||||
|
* |
||||||
|
* @param \Illuminate\Http\Request $request |
||||||
|
* @return mixed |
||||||
|
*/ |
||||||
|
public function store(Request $request) |
||||||
|
{ |
||||||
|
if (! Auth::guard('web')->validate([ |
||||||
|
'email' => $request->user()->email, |
||||||
|
'password' => $request->password, |
||||||
|
])) { |
||||||
|
throw ValidationException::withMessages([ |
||||||
|
'password' => __('auth.password'), |
||||||
|
]); |
||||||
|
} |
||||||
|
|
||||||
|
$request->session()->put('auth.password_confirmed_at', time()); |
||||||
|
|
||||||
|
return redirect()->intended(RouteServiceProvider::HOME); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,27 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth; |
||||||
|
|
||||||
|
use App\Http\Controllers\Controller; |
||||||
|
use App\Providers\RouteServiceProvider; |
||||||
|
use Illuminate\Http\Request; |
||||||
|
|
||||||
|
class EmailVerificationNotificationController extends Controller |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Send a new email verification notification. |
||||||
|
* |
||||||
|
* @param \Illuminate\Http\Request $request |
||||||
|
* @return \Illuminate\Http\RedirectResponse |
||||||
|
*/ |
||||||
|
public function store(Request $request) |
||||||
|
{ |
||||||
|
if ($request->user()->hasVerifiedEmail()) { |
||||||
|
return redirect()->intended(RouteServiceProvider::HOME); |
||||||
|
} |
||||||
|
|
||||||
|
$request->user()->sendEmailVerificationNotification(); |
||||||
|
|
||||||
|
return back()->with('status', 'verification-link-sent'); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,23 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth; |
||||||
|
|
||||||
|
use App\Http\Controllers\Controller; |
||||||
|
use App\Providers\RouteServiceProvider; |
||||||
|
use Illuminate\Http\Request; |
||||||
|
|
||||||
|
class EmailVerificationPromptController extends Controller |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Display the email verification prompt. |
||||||
|
* |
||||||
|
* @param \Illuminate\Http\Request $request |
||||||
|
* @return mixed |
||||||
|
*/ |
||||||
|
public function __invoke(Request $request) |
||||||
|
{ |
||||||
|
return $request->user()->hasVerifiedEmail() |
||||||
|
? redirect()->intended(RouteServiceProvider::HOME) |
||||||
|
: view('auth.verify-email'); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,65 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth; |
||||||
|
|
||||||
|
use App\Http\Controllers\Controller; |
||||||
|
use Illuminate\Auth\Events\PasswordReset; |
||||||
|
use Illuminate\Http\Request; |
||||||
|
use Illuminate\Support\Facades\Hash; |
||||||
|
use Illuminate\Support\Facades\Password; |
||||||
|
use Illuminate\Support\Str; |
||||||
|
use Illuminate\Validation\Rules; |
||||||
|
|
||||||
|
class NewPasswordController extends Controller |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Display the password reset view. |
||||||
|
* |
||||||
|
* @param \Illuminate\Http\Request $request |
||||||
|
* @return \Illuminate\View\View |
||||||
|
*/ |
||||||
|
public function create(Request $request) |
||||||
|
{ |
||||||
|
return view('auth.reset-password', ['request' => $request]); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Handle an incoming new password request. |
||||||
|
* |
||||||
|
* @param \Illuminate\Http\Request $request |
||||||
|
* @return \Illuminate\Http\RedirectResponse |
||||||
|
* |
||||||
|
* @throws \Illuminate\Validation\ValidationException |
||||||
|
*/ |
||||||
|
public function store(Request $request) |
||||||
|
{ |
||||||
|
$request->validate([ |
||||||
|
'token' => ['required'], |
||||||
|
'email' => ['required', 'email'], |
||||||
|
'password' => ['required', 'confirmed', Rules\Password::defaults()], |
||||||
|
]); |
||||||
|
|
||||||
|
// Here we will attempt to reset the user's password. If it is successful we |
||||||
|
// will update the password on an actual user model and persist it to the |
||||||
|
// database. Otherwise we will parse the error and return the response. |
||||||
|
$status = Password::reset( |
||||||
|
$request->only('email', 'password', 'password_confirmation', 'token'), |
||||||
|
function ($user) use ($request) { |
||||||
|
$user->forceFill([ |
||||||
|
'password' => Hash::make($request->password), |
||||||
|
'remember_token' => Str::random(60), |
||||||
|
])->save(); |
||||||
|
|
||||||
|
event(new PasswordReset($user)); |
||||||
|
} |
||||||
|
); |
||||||
|
|
||||||
|
// If the password was successfully reset, we will redirect the user back to |
||||||
|
// the application's home authenticated view. If there is an error we can |
||||||
|
// redirect them back to where they came from with their error message. |
||||||
|
return $status == Password::PASSWORD_RESET |
||||||
|
? redirect()->route('login')->with('status', __($status)) |
||||||
|
: back()->withInput($request->only('email')) |
||||||
|
->withErrors(['email' => __($status)]); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,47 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth; |
||||||
|
|
||||||
|
use App\Http\Controllers\Controller; |
||||||
|
use Illuminate\Http\Request; |
||||||
|
use Illuminate\Support\Facades\Password; |
||||||
|
|
||||||
|
class PasswordResetLinkController extends Controller |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Display the password reset link request view. |
||||||
|
* |
||||||
|
* @return \Illuminate\View\View |
||||||
|
*/ |
||||||
|
public function create() |
||||||
|
{ |
||||||
|
return view('auth.forgot-password'); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Handle an incoming password reset link request. |
||||||
|
* |
||||||
|
* @param \Illuminate\Http\Request $request |
||||||
|
* @return \Illuminate\Http\RedirectResponse |
||||||
|
* |
||||||
|
* @throws \Illuminate\Validation\ValidationException |
||||||
|
*/ |
||||||
|
public function store(Request $request) |
||||||
|
{ |
||||||
|
$request->validate([ |
||||||
|
'email' => ['required', 'email'], |
||||||
|
]); |
||||||
|
|
||||||
|
// We will send the password reset link to this user. Once we have attempted |
||||||
|
// to send the link, we will examine the response then see the message we |
||||||
|
// need to show to the user. Finally, we'll send out a proper response. |
||||||
|
$status = Password::sendResetLink( |
||||||
|
$request->only('email') |
||||||
|
); |
||||||
|
|
||||||
|
return $status == Password::RESET_LINK_SENT |
||||||
|
? back()->with('status', __($status)) |
||||||
|
: back()->withInput($request->only('email')) |
||||||
|
->withErrors(['email' => __($status)]); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,54 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth; |
||||||
|
|
||||||
|
use App\Http\Controllers\Controller; |
||||||
|
use App\Models\User; |
||||||
|
use App\Providers\RouteServiceProvider; |
||||||
|
use Illuminate\Auth\Events\Registered; |
||||||
|
use Illuminate\Http\Request; |
||||||
|
use Illuminate\Support\Facades\Auth; |
||||||
|
use Illuminate\Support\Facades\Hash; |
||||||
|
use Illuminate\Validation\Rules; |
||||||
|
|
||||||
|
class RegisteredUserController extends Controller |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Display the registration view. |
||||||
|
* |
||||||
|
* @return \Illuminate\View\View |
||||||
|
*/ |
||||||
|
public function create() |
||||||
|
{ |
||||||
|
return view('auth.register'); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Handle an incoming registration request. |
||||||
|
* |
||||||
|
* @param \Illuminate\Http\Request $request |
||||||
|
* @return \Illuminate\Http\RedirectResponse |
||||||
|
* |
||||||
|
* @throws \Illuminate\Validation\ValidationException |
||||||
|
*/ |
||||||
|
public function store(Request $request) |
||||||
|
{ |
||||||
|
$request->validate([ |
||||||
|
'name' => ['required', 'string', 'max:255'], |
||||||
|
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], |
||||||
|
'password' => ['required', 'confirmed', Rules\Password::defaults()], |
||||||
|
]); |
||||||
|
|
||||||
|
$user = User::create([ |
||||||
|
'name' => $request->name, |
||||||
|
'email' => $request->email, |
||||||
|
'password' => Hash::make($request->password), |
||||||
|
]); |
||||||
|
|
||||||
|
event(new Registered($user)); |
||||||
|
|
||||||
|
Auth::login($user); |
||||||
|
|
||||||
|
return redirect(RouteServiceProvider::HOME); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,30 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth; |
||||||
|
|
||||||
|
use App\Http\Controllers\Controller; |
||||||
|
use App\Providers\RouteServiceProvider; |
||||||
|
use Illuminate\Auth\Events\Verified; |
||||||
|
use Illuminate\Foundation\Auth\EmailVerificationRequest; |
||||||
|
|
||||||
|
class VerifyEmailController extends Controller |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Mark the authenticated user's email address as verified. |
||||||
|
* |
||||||
|
* @param \Illuminate\Foundation\Auth\EmailVerificationRequest $request |
||||||
|
* @return \Illuminate\Http\RedirectResponse |
||||||
|
*/ |
||||||
|
public function __invoke(EmailVerificationRequest $request) |
||||||
|
{ |
||||||
|
if ($request->user()->hasVerifiedEmail()) { |
||||||
|
return redirect()->intended(RouteServiceProvider::HOME.'?verified=1'); |
||||||
|
} |
||||||
|
|
||||||
|
if ($request->user()->markEmailAsVerified()) { |
||||||
|
event(new Verified($request->user())); |
||||||
|
} |
||||||
|
|
||||||
|
return redirect()->intended(RouteServiceProvider::HOME.'?verified=1'); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,85 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Http\Controllers; |
||||||
|
|
||||||
|
use App\Models\Home; |
||||||
|
use Illuminate\Http\Request; |
||||||
|
|
||||||
|
class HomeController extends Controller |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Display a listing of the resource. |
||||||
|
* |
||||||
|
* @return \Illuminate\Http\Response |
||||||
|
*/ |
||||||
|
public function index() |
||||||
|
{ |
||||||
|
return view('home.index'); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Show the form for creating a new resource. |
||||||
|
* |
||||||
|
* @return \Illuminate\Http\Response |
||||||
|
*/ |
||||||
|
public function create() |
||||||
|
{ |
||||||
|
// |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Store a newly created resource in storage. |
||||||
|
* |
||||||
|
* @param \Illuminate\Http\Request $request |
||||||
|
* @return \Illuminate\Http\Response |
||||||
|
*/ |
||||||
|
public function store(Request $request) |
||||||
|
{ |
||||||
|
// |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Display the specified resource. |
||||||
|
* |
||||||
|
* @param \App\Models\Home $home |
||||||
|
* @return \Illuminate\Http\Response |
||||||
|
*/ |
||||||
|
public function show(Home $home) |
||||||
|
{ |
||||||
|
// |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Show the form for editing the specified resource. |
||||||
|
* |
||||||
|
* @param \App\Models\Home $home |
||||||
|
* @return \Illuminate\Http\Response |
||||||
|
*/ |
||||||
|
public function edit(Home $home) |
||||||
|
{ |
||||||
|
// |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Update the specified resource in storage. |
||||||
|
* |
||||||
|
* @param \Illuminate\Http\Request $request |
||||||
|
* @param \App\Models\Home $home |
||||||
|
* @return \Illuminate\Http\Response |
||||||
|
*/ |
||||||
|
public function update(Request $request, Home $home) |
||||||
|
{ |
||||||
|
// |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Remove the specified resource from storage. |
||||||
|
* |
||||||
|
* @param \App\Models\Home $home |
||||||
|
* @return \Illuminate\Http\Response |
||||||
|
*/ |
||||||
|
public function destroy(Home $home) |
||||||
|
{ |
||||||
|
// |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,94 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Http\Controllers; |
||||||
|
|
||||||
|
use Illuminate\Http\Request; |
||||||
|
|
||||||
|
class RoleController extends Controller |
||||||
|
{ |
||||||
|
|
||||||
|
public function __construct() |
||||||
|
{ |
||||||
|
$this->middleware('can:create role')->only('create'); |
||||||
|
} |
||||||
|
/** |
||||||
|
* Display a listing of the resource. |
||||||
|
* |
||||||
|
* @return \Illuminate\Http\Response |
||||||
|
*/ |
||||||
|
public function index(Request $request) |
||||||
|
{ |
||||||
|
// $this->authorize('read role'); |
||||||
|
// if(Gate::allows('read role')){ |
||||||
|
// abort(403, 'unauthorized'); |
||||||
|
// } |
||||||
|
|
||||||
|
return view('role.index'); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Show the form for creating a new resource. |
||||||
|
* |
||||||
|
* @return \Illuminate\Http\Response |
||||||
|
*/ |
||||||
|
public function create() |
||||||
|
{ |
||||||
|
// |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Store a newly created resource in storage. |
||||||
|
* |
||||||
|
* @param \Illuminate\Http\Request $request |
||||||
|
* @return \Illuminate\Http\Response |
||||||
|
*/ |
||||||
|
public function store(Request $request) |
||||||
|
{ |
||||||
|
// |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Display the specified resource. |
||||||
|
* |
||||||
|
* @param int $id |
||||||
|
* @return \Illuminate\Http\Response |
||||||
|
*/ |
||||||
|
public function show($id) |
||||||
|
{ |
||||||
|
// |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Show the form for editing the specified resource. |
||||||
|
* |
||||||
|
* @param int $id |
||||||
|
* @return \Illuminate\Http\Response |
||||||
|
*/ |
||||||
|
public function edit($id) |
||||||
|
{ |
||||||
|
// |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Update the specified resource in storage. |
||||||
|
* |
||||||
|
* @param \Illuminate\Http\Request $request |
||||||
|
* @param int $id |
||||||
|
* @return \Illuminate\Http\Response |
||||||
|
*/ |
||||||
|
public function update(Request $request, $id) |
||||||
|
{ |
||||||
|
// |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Remove the specified resource from storage. |
||||||
|
* |
||||||
|
* @param int $id |
||||||
|
* @return \Illuminate\Http\Response |
||||||
|
*/ |
||||||
|
public function destroy($id) |
||||||
|
{ |
||||||
|
// |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,93 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Http\Requests\Auth; |
||||||
|
|
||||||
|
use Illuminate\Auth\Events\Lockout; |
||||||
|
use Illuminate\Foundation\Http\FormRequest; |
||||||
|
use Illuminate\Support\Facades\Auth; |
||||||
|
use Illuminate\Support\Facades\RateLimiter; |
||||||
|
use Illuminate\Support\Str; |
||||||
|
use Illuminate\Validation\ValidationException; |
||||||
|
|
||||||
|
class LoginRequest extends FormRequest |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Determine if the user is authorized to make this request. |
||||||
|
* |
||||||
|
* @return bool |
||||||
|
*/ |
||||||
|
public function authorize() |
||||||
|
{ |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the validation rules that apply to the request. |
||||||
|
* |
||||||
|
* @return array |
||||||
|
*/ |
||||||
|
public function rules() |
||||||
|
{ |
||||||
|
return [ |
||||||
|
'email' => ['required', 'string', 'email'], |
||||||
|
'password' => ['required', 'string'], |
||||||
|
]; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Attempt to authenticate the request's credentials. |
||||||
|
* |
||||||
|
* @return void |
||||||
|
* |
||||||
|
* @throws \Illuminate\Validation\ValidationException |
||||||
|
*/ |
||||||
|
public function authenticate() |
||||||
|
{ |
||||||
|
$this->ensureIsNotRateLimited(); |
||||||
|
|
||||||
|
if (! Auth::attempt($this->only('email', 'password'), $this->boolean('remember'))) { |
||||||
|
RateLimiter::hit($this->throttleKey()); |
||||||
|
|
||||||
|
throw ValidationException::withMessages([ |
||||||
|
'email' => trans('auth.failed'), |
||||||
|
]); |
||||||
|
} |
||||||
|
|
||||||
|
RateLimiter::clear($this->throttleKey()); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Ensure the login request is not rate limited. |
||||||
|
* |
||||||
|
* @return void |
||||||
|
* |
||||||
|
* @throws \Illuminate\Validation\ValidationException |
||||||
|
*/ |
||||||
|
public function ensureIsNotRateLimited() |
||||||
|
{ |
||||||
|
if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
event(new Lockout($this)); |
||||||
|
|
||||||
|
$seconds = RateLimiter::availableIn($this->throttleKey()); |
||||||
|
|
||||||
|
throw ValidationException::withMessages([ |
||||||
|
'email' => trans('auth.throttle', [ |
||||||
|
'seconds' => $seconds, |
||||||
|
'minutes' => ceil($seconds / 60), |
||||||
|
]), |
||||||
|
]); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the rate limiting throttle key for the request. |
||||||
|
* |
||||||
|
* @return string |
||||||
|
*/ |
||||||
|
public function throttleKey() |
||||||
|
{ |
||||||
|
return Str::lower($this->input('email')).'|'.$this->ip(); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,11 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Models; |
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory; |
||||||
|
use Illuminate\Database\Eloquent\Model; |
||||||
|
|
||||||
|
class Home extends Model |
||||||
|
{ |
||||||
|
use HasFactory; |
||||||
|
} |
||||||
@ -0,0 +1,18 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\View\Components; |
||||||
|
|
||||||
|
use Illuminate\View\Component; |
||||||
|
|
||||||
|
class AppLayout extends Component |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Get the view / contents that represents the component. |
||||||
|
* |
||||||
|
* @return \Illuminate\View\View |
||||||
|
*/ |
||||||
|
public function render() |
||||||
|
{ |
||||||
|
return view('layouts.app'); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,18 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\View\Components; |
||||||
|
|
||||||
|
use Illuminate\View\Component; |
||||||
|
|
||||||
|
class GuestLayout extends Component |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Get the view / contents that represents the component. |
||||||
|
* |
||||||
|
* @return \Illuminate\View\View |
||||||
|
*/ |
||||||
|
public function render() |
||||||
|
{ |
||||||
|
return view('layouts.guest'); |
||||||
|
} |
||||||
|
} |
||||||
@ -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,141 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema; |
||||||
|
use Illuminate\Database\Schema\Blueprint; |
||||||
|
use Illuminate\Database\Migrations\Migration; |
||||||
|
use Spatie\Permission\PermissionRegistrar; |
||||||
|
|
||||||
|
class CreatePermissionTables extends Migration |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Run the migrations. |
||||||
|
* |
||||||
|
* @return void |
||||||
|
*/ |
||||||
|
public function up() |
||||||
|
{ |
||||||
|
$tableNames = config('permission.table_names'); |
||||||
|
$columnNames = config('permission.column_names'); |
||||||
|
$teams = config('permission.teams'); |
||||||
|
|
||||||
|
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, $teams) { |
||||||
|
$table->unsignedBigInteger(PermissionRegistrar::$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(PermissionRegistrar::$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'], PermissionRegistrar::$pivotPermission, $columnNames['model_morph_key'], 'model_type'], |
||||||
|
'model_has_permissions_permission_model_type_primary'); |
||||||
|
} else { |
||||||
|
$table->primary([PermissionRegistrar::$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, $teams) { |
||||||
|
$table->unsignedBigInteger(PermissionRegistrar::$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(PermissionRegistrar::$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'], PermissionRegistrar::$pivotRole, $columnNames['model_morph_key'], 'model_type'], |
||||||
|
'model_has_roles_role_model_type_primary'); |
||||||
|
} else { |
||||||
|
$table->primary([PermissionRegistrar::$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) { |
||||||
|
$table->unsignedBigInteger(PermissionRegistrar::$pivotPermission); |
||||||
|
$table->unsignedBigInteger(PermissionRegistrar::$pivotRole); |
||||||
|
|
||||||
|
$table->foreign(PermissionRegistrar::$pivotPermission) |
||||||
|
->references('id') // permission id |
||||||
|
->on($tableNames['permissions']) |
||||||
|
->onDelete('cascade'); |
||||||
|
|
||||||
|
$table->foreign(PermissionRegistrar::$pivotRole) |
||||||
|
->references('id') // role id |
||||||
|
->on($tableNames['roles']) |
||||||
|
->onDelete('cascade'); |
||||||
|
|
||||||
|
$table->primary([PermissionRegistrar::$pivotPermission, PermissionRegistrar::$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. |
||||||
|
* |
||||||
|
* @return void |
||||||
|
*/ |
||||||
|
public function down() |
||||||
|
{ |
||||||
|
$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,64 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace Database\Seeders; |
||||||
|
|
||||||
|
use DB; |
||||||
|
|
||||||
|
use Illuminate\Database\Seeder; |
||||||
|
use App\Models\User; |
||||||
|
use Illuminate\Support\Str; |
||||||
|
use Spatie\Permission\Models\Role; |
||||||
|
use Spatie\Permission\Models\Permission; |
||||||
|
|
||||||
|
class UserRolePermissionSeeder extends Seeder |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Run the database seeds. |
||||||
|
* |
||||||
|
* @return void |
||||||
|
*/ |
||||||
|
public function run() |
||||||
|
{ |
||||||
|
$default_user_value = [ |
||||||
|
'email_verified_at' => now(), |
||||||
|
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password |
||||||
|
'remember_token' => Str::random(10), |
||||||
|
]; |
||||||
|
|
||||||
|
DB::beginTransaction(); |
||||||
|
try { |
||||||
|
//code... |
||||||
|
|
||||||
|
|
||||||
|
$admin = User::create(array_merge([ |
||||||
|
'email' => 'admin@gmail.com', |
||||||
|
'name' => 'admin', |
||||||
|
], $default_user_value)); |
||||||
|
|
||||||
|
$staff = User::create(array_merge([ |
||||||
|
'email' => 'staff@gmail.com', |
||||||
|
'name' => 'staff', |
||||||
|
], $default_user_value)); |
||||||
|
|
||||||
|
$role_admin = Role::create(['name' => 'admin']); |
||||||
|
$role_staff = Role::create(['name' => 'staff']); |
||||||
|
|
||||||
|
$permission = Permission::create(['name' => 'read role']); |
||||||
|
$permission = Permission::create(['name' => 'create role']); |
||||||
|
$permission = Permission::create(['name' => 'update role']); |
||||||
|
$permission = Permission::create(['name' => 'delete role']); |
||||||
|
|
||||||
|
$role_admin->givePermissionTo('read role'); |
||||||
|
$role_admin->givePermissionTo('create role'); |
||||||
|
$role_admin->givePermissionTo('update role'); |
||||||
|
$role_admin->givePermissionTo('delete role'); |
||||||
|
|
||||||
|
$admin->assignRole('admin'); |
||||||
|
$staff->assignRole('staff'); |
||||||
|
|
||||||
|
DB::commit(); |
||||||
|
} catch (\Throwable $th) { |
||||||
|
throw $th; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,6 @@ |
|||||||
|
module.exports = { |
||||||
|
plugins: { |
||||||
|
tailwindcss: {}, |
||||||
|
autoprefixer: {}, |
||||||
|
}, |
||||||
|
}; |
||||||
|
Before Width: | Height: | Size: 479 B |
|
Before Width: | Height: | Size: 518 B |
|
Before Width: | Height: | Size: 257 B |
|
Before Width: | Height: | Size: 294 B |
|
Before Width: | Height: | Size: 458 B |
|
Before Width: | Height: | Size: 487 B |
|
Before Width: | Height: | Size: 608 B |
|
Before Width: | Height: | Size: 637 B |
|
Before Width: | Height: | Size: 391 B |
|
Before Width: | Height: | Size: 440 B |
|
Before Width: | Height: | Size: 496 B |
|
Before Width: | Height: | Size: 523 B |
|
Before Width: | Height: | Size: 619 B |
|
Before Width: | Height: | Size: 665 B |
|
Before Width: | Height: | Size: 252 B |
|
Before Width: | Height: | Size: 288 B |
|
Before Width: | Height: | Size: 694 B |
|
Before Width: | Height: | Size: 741 B |
|
Before Width: | Height: | Size: 575 B |
|
Before Width: | Height: | Size: 623 B |
|
Before Width: | Height: | Size: 690 B |
|
Before Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 493 B |
|
Before Width: | Height: | Size: 626 B |
|
Before Width: | Height: | Size: 271 B |
|
Before Width: | Height: | Size: 315 B |
|
Before Width: | Height: | Size: 318 B |
|
Before Width: | Height: | Size: 316 B |
|
Before Width: | Height: | Size: 318 B |
|
Before Width: | Height: | Size: 287 B |
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 387 B |
|
Before Width: | Height: | Size: 359 B |
|
Before Width: | Height: | Size: 350 B |
|
Before Width: | Height: | Size: 349 B |
|
Before Width: | Height: | Size: 350 B |
|
Before Width: | Height: | Size: 349 B |
|
Before Width: | Height: | Size: 375 B |
|
Before Width: | Height: | Size: 375 B |
|
Before Width: | Height: | Size: 375 B |
|
Before Width: | Height: | Size: 376 B |
|
Before Width: | Height: | Size: 352 B |