git commit -m "add register page, validation and auth routes"
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum UserStatus: int
|
||||
{
|
||||
case Draft = 0;
|
||||
case Active = 1 ;
|
||||
case Inactive = 2;
|
||||
case Expired = 3;
|
||||
case Cancelled = 4 ;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,13 @@
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Enums\UserStatus;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\RegisterRequest;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class RegisterController extends Controller
|
||||
{
|
||||
@@ -16,8 +21,35 @@ class RegisterController extends Controller
|
||||
return view('auth.register',compact('withoutHeader','withoutFooter','withoutHero'));
|
||||
}
|
||||
|
||||
public function post()
|
||||
public function post(RegisterRequest $request)
|
||||
{
|
||||
$inputs = $request->validated();
|
||||
|
||||
if ($request->hasFile('image')) {
|
||||
|
||||
$image = $request->file('image');
|
||||
|
||||
$imageName = time() . '.' . $image->getClientOriginalExtension();
|
||||
|
||||
$image->move(
|
||||
public_path('uploads/users'),
|
||||
$imageName
|
||||
);
|
||||
|
||||
$inputs['image'] = $imageName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$inputs['password']=Hash::make($inputs['password']);
|
||||
$inputs['status']=UserStatus::Draft;
|
||||
|
||||
$user= User::create($inputs);
|
||||
|
||||
Auth::login($user);
|
||||
|
||||
return redirect()->route('index');
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class IndexController extends Controller
|
||||
{
|
||||
//
|
||||
public function index()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ class RegisterRequest extends FormRequest
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -23,7 +23,80 @@ class RegisterRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
'first_name' => [
|
||||
'required',
|
||||
'persian_alpha',
|
||||
'string',
|
||||
'max:255'
|
||||
],
|
||||
|
||||
'last_name' => [
|
||||
'required',
|
||||
'persian_alpha',
|
||||
'string',
|
||||
'max:255'
|
||||
],
|
||||
|
||||
'national_code' => [
|
||||
'required',
|
||||
'unique:users,national_code'
|
||||
],
|
||||
|
||||
'gender' => [
|
||||
'required',
|
||||
'in:0,1'
|
||||
],
|
||||
|
||||
'marital_status' => [
|
||||
'required',
|
||||
'in:0,1,2'
|
||||
],
|
||||
|
||||
'spouse_name' => [
|
||||
'nullable'
|
||||
],
|
||||
|
||||
'mobile' => [
|
||||
'required',
|
||||
'unique:users,mobile',
|
||||
'ir_mobile:zero_code'
|
||||
],
|
||||
|
||||
'email' => [
|
||||
'required',
|
||||
'email',
|
||||
'unique:users,email',
|
||||
'ir_national_id'
|
||||
],
|
||||
|
||||
'username' => [
|
||||
'required',
|
||||
'unique:users,username'
|
||||
],
|
||||
'image' => [
|
||||
'nullable',
|
||||
'image',
|
||||
'mimes:jpg,jpeg,png,webp',
|
||||
'max:800',
|
||||
],
|
||||
|
||||
'province_id' => [
|
||||
'required',
|
||||
'exists:provinces,id',
|
||||
],
|
||||
|
||||
'city_id' => [
|
||||
'required',
|
||||
'exists:cities,id',
|
||||
],
|
||||
|
||||
|
||||
'password' => [
|
||||
'required',
|
||||
'confirmed',
|
||||
'min:8'
|
||||
],
|
||||
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -51,8 +51,8 @@ class User extends Model
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'Firstname',
|
||||
'Lastname',
|
||||
'first_name',
|
||||
'last_name',
|
||||
'national_code',
|
||||
'gender',
|
||||
'marital_status',
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
@section('content')
|
||||
<div class="theme-hero-area-bg-wrap">
|
||||
<div class="theme-hero-area-bg" style="background-image:url(img/adult-book-business-cactus-297755_1500x800.jpg);"></div>
|
||||
<div class="theme-hero-area-bg"
|
||||
style="background-image:url(img/adult-book-business-cactus-297755_1500x800.jpg);"></div>
|
||||
<div class="theme-hero-area-mask theme-hero-area-mask-strong"></div>
|
||||
</div>
|
||||
<div class="theme-hero-area-body">
|
||||
@@ -17,54 +18,315 @@
|
||||
</div>
|
||||
<div class="theme-login-box">
|
||||
<div class="theme-login-box-inner">
|
||||
<form class="theme-login-form" action="{{ route('auth.register.post') }}" method="POST">
|
||||
<form class="theme-login-form" action="{{ route('auth.register.post') }}"
|
||||
method="POST"
|
||||
enctype="multipart/form-data">>
|
||||
@csrf
|
||||
<div class="form-group theme-login-form-group">
|
||||
<input class="form-control" type="text" placeholder="آدرس ایمیل">
|
||||
<div>
|
||||
<label for="first_name"
|
||||
class="block text-sm/6 font-medium text-gray-500 dark:text-gray-300">
|
||||
نام
|
||||
</label>
|
||||
<div class="mt-3">
|
||||
<input
|
||||
type="text"
|
||||
id="first_name"
|
||||
name="first_name"
|
||||
autofocus
|
||||
tabindex="1"
|
||||
value="{{old('first_name')}}"
|
||||
class="block w-full p-3 text-base outline dark:outline-none outline-1 -outline-offset-1 placeholder:text-gray-400 sm:text-sm/6 transition-all text-gray-800 dark:text-gray-100 dark:bg-gray-900 bg-slate-100 border border-transparent hover:border-slate-200 appearance-none rounded-md outline-none focus:bg-white focus:border-indigo-400 focus:ring-2 focus:ring-indigo-100 dark:focus:ring-blue-400"
|
||||
/>
|
||||
</div>
|
||||
<div class="form-group theme-login-form-group">
|
||||
<input class="form-control" type="password" placeholder="رمز عبور ایجاد کنید">
|
||||
@error('first_name')
|
||||
<span>{{$message}}</span>
|
||||
@enderror
|
||||
</div>
|
||||
<a class="btn btn-uc btn-dark btn-block btn-lg" href="#">ایجاد حساب کاربری</a>
|
||||
</form>
|
||||
<div class="theme-login-social-separator">
|
||||
<p>یا با شبکه های اجتماعی ثبت نام کنید</p>
|
||||
<div>
|
||||
<label for="last_name"
|
||||
class="block text-sm/6 font-medium text-gray-500 dark:text-gray-300">
|
||||
نام خانوادگی
|
||||
</label>
|
||||
<div class="mt-3">
|
||||
<input
|
||||
type="text"
|
||||
id="last_name"
|
||||
name="last_name"
|
||||
autofocus
|
||||
tabindex="1"
|
||||
value="{{old('last_name')}}"
|
||||
class="block w-full p-3 text-base outline dark:outline-none outline-1 -outline-offset-1 placeholder:text-gray-400 sm:text-sm/6 transition-all text-gray-800 dark:text-gray-100 dark:bg-gray-900 bg-slate-100 border border-transparent hover:border-slate-200 appearance-none rounded-md outline-none focus:bg-white focus:border-indigo-400 focus:ring-2 focus:ring-indigo-100 dark:focus:ring-blue-400"
|
||||
/>
|
||||
</div>
|
||||
@error('last_name')
|
||||
<span>{{$message}}</span>
|
||||
@enderror
|
||||
</div>
|
||||
<div>
|
||||
<label for="national_code"
|
||||
class="block text-sm/6 font-medium text-gray-500 dark:text-gray-300">
|
||||
کدملی
|
||||
</label>
|
||||
<div class="mt-3">
|
||||
<input
|
||||
type="text"
|
||||
id="national_code"
|
||||
name="national_code"
|
||||
autofocus
|
||||
tabindex="1"
|
||||
value="{{old('national_code')}}"
|
||||
class="block w-full p-3 text-base outline dark:outline-none outline-1 -outline-offset-1 placeholder:text-gray-400 sm:text-sm/6 transition-all text-gray-800 dark:text-gray-100 dark:bg-gray-900 bg-slate-100 border border-transparent hover:border-slate-200 appearance-none rounded-md outline-none focus:bg-white focus:border-indigo-400 focus:ring-2 focus:ring-indigo-100 dark:focus:ring-blue-400"
|
||||
/>
|
||||
</div>
|
||||
@error('national_code')
|
||||
<span>{{$message}}</span>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="theme-login-social-login">
|
||||
<div class="row" data-gutter="10">
|
||||
<div class="col-xs-6">
|
||||
<a class="theme-login-social-login-facebook" href="#">
|
||||
<i class="fa fa-facebook-square"></i>
|
||||
<span>با
|
||||
<br>
|
||||
<b>فیس بوک ثبت نام کنید</b>
|
||||
</span>
|
||||
</a>
|
||||
|
||||
|
||||
<div class="col-md-6">
|
||||
|
||||
<select class="form-control"
|
||||
name="gender">
|
||||
|
||||
<option value="">
|
||||
جنسیت
|
||||
</option>
|
||||
|
||||
<option value="0">
|
||||
مرد
|
||||
</option>
|
||||
|
||||
<option value="1">
|
||||
زن
|
||||
</option>
|
||||
|
||||
</select>
|
||||
@error('gender')
|
||||
<span>{{$message}}</span>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
<a class="theme-login-social-login-google" href="#">
|
||||
<i class="fa fa-google-plus-circle"></i>
|
||||
<span>با
|
||||
<br>
|
||||
<b>گوگل ثبت نام کنید</b>
|
||||
</span>
|
||||
</a>
|
||||
|
||||
|
||||
<div class="col-md-6">
|
||||
|
||||
<select class="form-control"
|
||||
name="marital_status">
|
||||
|
||||
<option value="">
|
||||
وضعیت تاهل
|
||||
</option>
|
||||
|
||||
<option value="0">
|
||||
مجرد
|
||||
</option>
|
||||
|
||||
<option value="1">
|
||||
متاهل
|
||||
</option>
|
||||
|
||||
<option value="2">
|
||||
متارکه
|
||||
</option>
|
||||
|
||||
</select>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@error('marital_status')
|
||||
<span>{{$message}}</span>
|
||||
@enderror
|
||||
</div>
|
||||
<div>
|
||||
<label for="spouse_name"
|
||||
class="block text-sm/6 font-medium text-gray-500 dark:text-gray-300">
|
||||
نام نام خانوادگی همسر
|
||||
|
||||
</label>
|
||||
<div class="mt-3">
|
||||
<input
|
||||
type="text"
|
||||
id="spouse_name"
|
||||
name="spouse_name"
|
||||
autofocus
|
||||
tabindex="1"
|
||||
value="{{old('spouse_name')}}"
|
||||
class="block w-full p-3 text-base outline dark:outline-none outline-1 -outline-offset-1 placeholder:text-gray-400 sm:text-sm/6 transition-all text-gray-800 dark:text-gray-100 dark:bg-gray-900 bg-slate-100 border border-transparent hover:border-slate-200 appearance-none rounded-md outline-none focus:bg-white focus:border-indigo-400 focus:ring-2 focus:ring-indigo-100 dark:focus:ring-blue-400"
|
||||
/>
|
||||
</div>
|
||||
@error('spouse_name')
|
||||
<span>{{$message}}</span>
|
||||
@enderror
|
||||
</div>
|
||||
<div>
|
||||
<label for="mobile"
|
||||
class="block text-sm/6 font-medium text-gray-500 dark:text-gray-300">
|
||||
موبایل
|
||||
|
||||
</label>
|
||||
<div class="mt-3">
|
||||
<input
|
||||
type="text"
|
||||
id="mobile"
|
||||
name="mobile"
|
||||
autofocus
|
||||
tabindex="1"
|
||||
value="{{old('mobile')}}"
|
||||
class="block w-full p-3 text-base outline dark:outline-none outline-1 -outline-offset-1 placeholder:text-gray-400 sm:text-sm/6 transition-all text-gray-800 dark:text-gray-100 dark:bg-gray-900 bg-slate-100 border border-transparent hover:border-slate-200 appearance-none rounded-md outline-none focus:bg-white focus:border-indigo-400 focus:ring-2 focus:ring-indigo-100 dark:focus:ring-blue-400"
|
||||
/>
|
||||
</div>
|
||||
@error('mobile')
|
||||
<span>{{$message}}</span>
|
||||
@enderror
|
||||
</div>
|
||||
<div>
|
||||
<label for="email"
|
||||
class="block text-sm/6 font-medium text-gray-500 dark:text-gray-300">
|
||||
ایمیل
|
||||
</label>
|
||||
<div class="mt-3">
|
||||
<input
|
||||
type="text"
|
||||
id="email"
|
||||
name="email"
|
||||
autofocus
|
||||
tabindex="1"
|
||||
value="{{old('email')}}"
|
||||
class="block w-full p-3 text-base outline dark:outline-none outline-1 -outline-offset-1 placeholder:text-gray-400 sm:text-sm/6 transition-all text-gray-800 dark:text-gray-100 dark:bg-gray-900 bg-slate-100 border border-transparent hover:border-slate-200 appearance-none rounded-md outline-none focus:bg-white focus:border-indigo-400 focus:ring-2 focus:ring-indigo-100 dark:focus:ring-blue-400"
|
||||
/>
|
||||
</div>
|
||||
@error('email')
|
||||
<span>{{$message}}</span>
|
||||
@enderror
|
||||
</div>
|
||||
<div>
|
||||
<label for="profile_image"
|
||||
class="block text-sm/6 font-medium text-gray-500 dark:text-gray-300">
|
||||
عکس
|
||||
|
||||
</label>
|
||||
<div class="mt-3">
|
||||
<input
|
||||
type="text"
|
||||
id="profile_image"
|
||||
name="profile_image"
|
||||
autofocus
|
||||
tabindex="1"
|
||||
value="{{old('profile_image')}}"
|
||||
class="block w-full p-3 text-base outline dark:outline-none outline-1 -outline-offset-1 placeholder:text-gray-400 sm:text-sm/6 transition-all text-gray-800 dark:text-gray-100 dark:bg-gray-900 bg-slate-100 border border-transparent hover:border-slate-200 appearance-none rounded-md outline-none focus:bg-white focus:border-indigo-400 focus:ring-2 focus:ring-indigo-100 dark:focus:ring-blue-400"
|
||||
/>
|
||||
</div>
|
||||
@error('profile_image')
|
||||
<span>{{$message}}</span>
|
||||
@enderror
|
||||
</div>
|
||||
<div>
|
||||
<label for="username"
|
||||
class="block text-sm/6 font-medium text-gray-500 dark:text-gray-300">
|
||||
نام کاربری
|
||||
</label>
|
||||
<div class="mt-3">
|
||||
<input
|
||||
type="text"
|
||||
id="username"
|
||||
name="username"
|
||||
autofocus
|
||||
tabindex="1"
|
||||
value="{{old('username')}}"
|
||||
class="block w-full p-3 text-base outline dark:outline-none outline-1 -outline-offset-1 placeholder:text-gray-400 sm:text-sm/6 transition-all text-gray-800 dark:text-gray-100 dark:bg-gray-900 bg-slate-100 border border-transparent hover:border-slate-200 appearance-none rounded-md outline-none focus:bg-white focus:border-indigo-400 focus:ring-2 focus:ring-indigo-100 dark:focus:ring-blue-400"
|
||||
/>
|
||||
</div>
|
||||
@error('username')
|
||||
<span>{{$message}}</span>
|
||||
@enderror
|
||||
</div>
|
||||
<div>
|
||||
<label for="password"
|
||||
class="block text-sm/6 font-medium text-gray-500 dark:text-gray-300">
|
||||
|
||||
رمز عبور
|
||||
</label>
|
||||
<div class="mt-3">
|
||||
<input
|
||||
type="text"
|
||||
id="password"
|
||||
name="password"
|
||||
autofocus
|
||||
tabindex="1"
|
||||
class="block w-full p-3 text-base outline dark:outline-none outline-1 -outline-offset-1 placeholder:text-gray-400 sm:text-sm/6 transition-all text-gray-800 dark:text-gray-100 dark:bg-gray-900 bg-slate-100 border border-transparent hover:border-slate-200 appearance-none rounded-md outline-none focus:bg-white focus:border-indigo-400 focus:ring-2 focus:ring-indigo-100 dark:focus:ring-blue-400"
|
||||
/>
|
||||
</div>
|
||||
@error('password')
|
||||
<span>{{$message}}</span>
|
||||
@enderror
|
||||
</div>
|
||||
<div>
|
||||
<label for="password"
|
||||
class="block text-sm/6 font-medium text-gray-500 dark:text-gray-300">
|
||||
تکرار رمز عبور
|
||||
</label>
|
||||
<div class="mt-3">
|
||||
<input
|
||||
type="password"
|
||||
tabindex="6"
|
||||
id="password"
|
||||
name="password_confirmation"
|
||||
class="block w-full p-3 text-base outline dark:outline-none outline-1 -outline-offset-1 placeholder:text-gray-400 sm:text-sm/6 transition-all text-gray-800 dark:text-gray-100 dark:bg-gray-900 bg-slate-100 border border-transparent hover:border-slate-200 appearance-none rounded-md outline-none focus:bg-white focus:border-indigo-400 focus:ring-2 focus:ring-indigo-100 dark:focus:ring-blue-400"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="province"
|
||||
class="block text-sm/6 font-medium text-gray-500 dark:text-gray-300">
|
||||
استان
|
||||
</label>
|
||||
<div class="mt-3">
|
||||
<input
|
||||
type="text"
|
||||
id="province"
|
||||
name="province"
|
||||
autofocus
|
||||
tabindex="1"
|
||||
value="{{old('province')}}"
|
||||
class="block w-full p-3 text-base outline dark:outline-none outline-1 -outline-offset-1 placeholder:text-gray-400 sm:text-sm/6 transition-all text-gray-800 dark:text-gray-100 dark:bg-gray-900 bg-slate-100 border border-transparent hover:border-slate-200 appearance-none rounded-md outline-none focus:bg-white focus:border-indigo-400 focus:ring-2 focus:ring-indigo-100 dark:focus:ring-blue-400"
|
||||
/>
|
||||
</div>
|
||||
@error('province')
|
||||
<span>{{$message}}</span>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="theme-login-box-alt">
|
||||
<p>از قبل حساب کاربری دارید؟
|
||||
<a href="login-2.html">ورود.</a>
|
||||
<div>
|
||||
<label for="city"
|
||||
class="block text-sm/6 font-medium text-gray-500 dark:text-gray-300">
|
||||
|
||||
شهرستان </label>
|
||||
<div class="mt-3">
|
||||
<input
|
||||
type="text"
|
||||
id="city"
|
||||
name="city"
|
||||
autofocus
|
||||
tabindex="1"
|
||||
value="{{old('city')}}"
|
||||
class="block w-full p-3 text-base outline dark:outline-none outline-1 -outline-offset-1 placeholder:text-gray-400 sm:text-sm/6 transition-all text-gray-800 dark:text-gray-100 dark:bg-gray-900 bg-slate-100 border border-transparent hover:border-slate-200 appearance-none rounded-md outline-none focus:bg-white focus:border-indigo-400 focus:ring-2 focus:ring-indigo-100 dark:focus:ring-blue-400"
|
||||
/>
|
||||
</div>
|
||||
@error('city')
|
||||
<span>{{$message}}</span>
|
||||
@enderror
|
||||
</div>
|
||||
<div>
|
||||
<button type="submit" class="submit-btn" tabindex="7" >ساخت حساب کاربری</button>
|
||||
</div>
|
||||
</form>
|
||||
<p class="mt-8 text-center text-sm/6 text-gray-500 dark:text-gray-300">
|
||||
حساب کاربری دارید ؟
|
||||
<a class="text-blue-400" href="{{route('auth.login.index')}}">ورود</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<p class="theme-login-terms"><a href="#">با ثبت نام، شرایط استفاده</a>
|
||||
<br> و
|
||||
<a href="#">سیاست حفظ حریم خصوصی</a> ما را می پذیرید
|
||||
.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,2 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Controllers\IndexController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
|
||||
Route::get('/', [IndexController::class, 'index'])->name('index');
|
||||
|
||||
Reference in New Issue
Block a user