collective login
This commit is contained in:
parent
45fbf0f378
commit
13c390c5af
16 changed files with 209 additions and 15 deletions
54
app/Http/Controllers/CollectiveController.php
Normal file
54
app/Http/Controllers/CollectiveController.php
Normal file
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\StoreCollectiveRequest;
|
||||
use App\Http\Requests\UpdateCollectiveRequest;
|
||||
use App\Models\Collective;
|
||||
|
||||
class CollectiveController extends Controller
|
||||
{
|
||||
public function dashboard()
|
||||
{
|
||||
return view('admin.dashboard');
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('admin.install');
|
||||
}
|
||||
|
||||
public function store(StoreCollectiveRequest $request)
|
||||
{
|
||||
$validated = $request->safe()->only([
|
||||
'title',
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
]);
|
||||
|
||||
$collective = Collective::store($validated);
|
||||
auth()->login($collective);
|
||||
return redirect()->route('dashboard')->with('success', 'Fanatic installed!');
|
||||
}
|
||||
|
||||
public function show(Collective $collective)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function edit(Collective $collective)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function update(UpdateCollectiveRequest $request, Collective $collective)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function destroy(Collective $collective)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
25
app/Http/Requests/StoreCollectiveRequest.php
Normal file
25
app/Http/Requests/StoreCollectiveRequest.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rules\Password;
|
||||
|
||||
class StoreCollectiveRequest extends FormRequest
|
||||
{
|
||||
|
||||
public function authorize() : bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules() : array
|
||||
{
|
||||
return [
|
||||
'title' => ['required', 'string', 'max:255'],
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'email' => ['required', 'email', 'max:100'],
|
||||
'password' => ['required', 'confirmed', Password::min(6)->letters()->numbers()],
|
||||
];
|
||||
}
|
||||
}
|
30
app/Http/Requests/UpdateCollectiveRequest.php
Normal file
30
app/Http/Requests/UpdateCollectiveRequest.php
Normal file
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateCollectiveRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
|
@ -39,4 +40,27 @@ class Collective extends Authenticatable
|
|||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
|
||||
/* -------------------------------------------------------------------------------- password ---- */
|
||||
|
||||
protected function password() : Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
set: fn ($value) => bcrypt($value),
|
||||
);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------------- store ---- */
|
||||
|
||||
public static function store(array $validated) : Collective
|
||||
{
|
||||
$collective = new Collective();
|
||||
$collective->title = $validated['title'];
|
||||
$collective->name = $validated['name'];
|
||||
$collective->email = $validated['email'];
|
||||
$collective->password = $validated['password'];
|
||||
$collective->save();
|
||||
|
||||
return $collective;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
'providers' => [
|
||||
'users' => [
|
||||
'driver' => 'eloquent',
|
||||
'model' => App\Models\User::class,
|
||||
'model' => App\Models\Collective::class,
|
||||
],
|
||||
|
||||
// 'users' => [
|
||||
|
|
|
@ -92,6 +92,10 @@ .form__btns:first-of-type {
|
|||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.form__error {
|
||||
color: #e20000;
|
||||
}
|
||||
|
||||
html, body {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
@ -109,7 +113,6 @@ .l-container {
|
|||
margin: 0 auto;
|
||||
background-color: #f8f8ff;
|
||||
border: 1px solid #7874ff;
|
||||
padding: 0 40px;
|
||||
}
|
||||
|
||||
.l-nav {
|
||||
|
@ -133,5 +136,13 @@ .l-nav__tab:last-child {
|
|||
}
|
||||
|
||||
.l-main {
|
||||
padding: 5px;
|
||||
padding: 10px 40px;
|
||||
}
|
||||
|
||||
.error {
|
||||
background-color: #87ff5f;
|
||||
border: 1px solid #30be00;
|
||||
padding: 10px;
|
||||
width: 60%;
|
||||
margin: 10px auto;
|
||||
}
|
||||
|
|
|
@ -68,4 +68,8 @@ h1 {
|
|||
|
||||
.form__btn {
|
||||
@extend %btn;
|
||||
}
|
||||
|
||||
.form__error {
|
||||
color: $c-red;
|
||||
}
|
|
@ -18,7 +18,6 @@ body {
|
|||
margin: 0 auto;
|
||||
background-color: #f8f8ff;
|
||||
border: 1px solid $c-main;
|
||||
padding: 0 40px;
|
||||
}
|
||||
|
||||
|
||||
|
@ -44,5 +43,5 @@ body {
|
|||
|
||||
|
||||
.l-main {
|
||||
padding: 5px;
|
||||
padding: 10px 40px;
|
||||
}
|
11
resources/sass/admin/_modules.scss
Normal file
11
resources/sass/admin/_modules.scss
Normal file
|
@ -0,0 +1,11 @@
|
|||
@use 'vars' as *;
|
||||
@use 'sass:color';
|
||||
|
||||
.error {
|
||||
background-color: color.scale($c-green, $lightness: 50%);
|
||||
border: 1px solid $c-green;
|
||||
|
||||
padding: 10px;
|
||||
width: 60%;
|
||||
margin: 10px auto;
|
||||
}
|
2
resources/sass/admin/_states.scss
Normal file
2
resources/sass/admin/_states.scss
Normal file
|
@ -0,0 +1,2 @@
|
|||
@use 'vars' as *;
|
||||
|
|
@ -13,6 +13,10 @@ $c-accent: #de7cff;
|
|||
$c-accent-light: color.scale($c-accent, $lightness: 40%);
|
||||
$c-accent-lightest: color.scale($c-accent, $lightness: 80%);
|
||||
|
||||
$c-green: #30be00;
|
||||
$c-yellow: #ebb000;
|
||||
$c-red: #e20000;
|
||||
|
||||
/* ------------------------------------------------------------------------------------ &BTN ---- */
|
||||
|
||||
@mixin hover($focus: false) {
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
@use 'base';
|
||||
@use 'layout';
|
||||
@use 'layout';
|
||||
@use 'modules';
|
||||
@use 'states';
|
5
resources/views/admin/dashboard.blade.php
Normal file
5
resources/views/admin/dashboard.blade.php
Normal file
|
@ -0,0 +1,5 @@
|
|||
@extends('admin.layout')
|
||||
|
||||
@section('content')
|
||||
<h1><span>Dashboard</span></h1>
|
||||
@endsection
|
|
@ -5,25 +5,33 @@
|
|||
<p>This is the installation page. You will only need to complete this once, but values can be
|
||||
changed after installation.</p>
|
||||
|
||||
<form action="{{-- route('collective.store') --}}" method="POST">
|
||||
<form action="{{ route('collectives.store') }}" method="POST">
|
||||
@csrf
|
||||
|
||||
<fieldset class="form__fieldset">
|
||||
<label class="form__label" for="title">Collective title:</label>
|
||||
<input class="form__input" type="text" name="title" id="title"
|
||||
<input class="form__input" type="text" name="title" id="title" required
|
||||
value="{{ old('title') }}">
|
||||
@error('title') <p class="form__error">{{ $message }}</p> @enderror
|
||||
|
||||
<label class="form__label" for="name">Your name:</label>
|
||||
<input class="form__input" type="text" id="name" name="name"
|
||||
<input class="form__input" type="text" id="name" name="name" required
|
||||
value="{{ old('name') }}">
|
||||
@error('name') <p class="form__error">{{ $message }}</p> @enderror
|
||||
|
||||
<label class="form__label" for="email">Your email:</label>
|
||||
<input class="form__input" type="email" id="email" name="email"
|
||||
<input class="form__input" type="email" id="email" name="email" required
|
||||
value="{{ old('email') }}">
|
||||
@error('email') <p class="form__error">{{ $message }}</p> @enderror
|
||||
|
||||
<label class="form__label" for="password">Your password:</label>
|
||||
<input class="form__input" type="password" id="password" name="password"
|
||||
value="{{ old('password') }}">
|
||||
<input class="form__input" type="password" id="password" name="password" required>
|
||||
@error('password') <p class="form__error">{{ $message }}</p> @enderror
|
||||
|
||||
<label class="form__label" for="password_confirmation">Confirm password:</label>
|
||||
<input class="form__input" type="password" id="password_confirmation"
|
||||
name="password_confirmation" required>
|
||||
@error('password_confirmation') <p class="form__error">{{ $message }}</p> @enderror
|
||||
|
||||
<div class="form__btns">
|
||||
<input class="form__btn" type="submit" value="Submit">
|
||||
|
|
|
@ -22,6 +22,20 @@
|
|||
@endauth
|
||||
|
||||
<main class="l-main">
|
||||
@yield('title')
|
||||
|
||||
@if (session()->has('success'))
|
||||
<p class="success">{{ session()->get('success') }}</p>
|
||||
@endif
|
||||
|
||||
@if (session()->has('error'))
|
||||
<p class="error">{{ session()->get('error') }}</p>
|
||||
@endif
|
||||
|
||||
@if (session()->has('warning'))
|
||||
<p class="warning">{{ session()->get('warning') }}</p>
|
||||
@endif
|
||||
|
||||
@yield('content')
|
||||
</main>
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
use App\Http\Controllers\CollectiveController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
/*
|
||||
|
@ -13,6 +14,6 @@
|
|||
|
|
||||
*/
|
||||
|
||||
Route::get('/fanatic/install', function () {
|
||||
return view('admin.install');
|
||||
});
|
||||
Route::get('/fanatic', [CollectiveController::class, 'dashboard'])->name('dashboard');
|
||||
Route::get('/fanatic/install', [CollectiveController::class, 'create'])->name('collectives.create');
|
||||
Route::post('/fanatic', [CollectiveController::class, 'store'])->name('collectives.store');
|
||||
|
|
Loading…
Reference in a new issue