changes
This commit is contained in:
parent
adfc826e9c
commit
5b3c44aa33
@ -18,7 +18,7 @@ class AuthenticationController extends Controller
|
||||
public function __construct()
|
||||
{
|
||||
$this->path = config('app.client_path');
|
||||
$ads = Advertisements::where('status', 1)->where('parent_advertisement',0)->get();
|
||||
$ads = Advertisements::where('status', 1)->where('parent_advertisement', 0)->get();
|
||||
$headerMenuItems = Menuitems::where(['parent_menu' => 0, "status" => 1, "menulocations_id" => 1])->with('children')->orderBy('display_order')->get();
|
||||
$footerMenuItems = Menuitems::where(['parent_menu' => 0, "status" => 1, "menulocations_id" => 2])->with('children')->orderBy('display_order')->get();
|
||||
$latestNews = News::where('status', 1)->inRandomOrder()->limit(4)->get();
|
||||
@ -32,32 +32,45 @@ class AuthenticationController extends Controller
|
||||
|
||||
public function login()
|
||||
{
|
||||
return view($this->path.'.auth.login');
|
||||
return view($this->path . '.auth.login');
|
||||
}
|
||||
|
||||
public function register()
|
||||
{
|
||||
return view($this->path.'.auth.registration');
|
||||
return view($this->path . '.auth.registration');
|
||||
}
|
||||
|
||||
public static function store(Request $request)
|
||||
{
|
||||
dd($request->all());
|
||||
$request->validate([
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
|
||||
'password' => ['required', 'string', 'min:8', 'confirmed'],
|
||||
'password' => ['required', 'string', 'min:8'],
|
||||
'phone' => ['required', 'integer'],
|
||||
]);
|
||||
|
||||
User::create([
|
||||
'name' => $request->name,
|
||||
'email' => $request->email,
|
||||
'password' => bcrypt($request->password),
|
||||
'username' => $request->name
|
||||
]);
|
||||
'username' => $request->name,
|
||||
'phone' => $request->phone,
|
||||
'status' => 1,
|
||||
'email_verified_at' => now()
|
||||
])->assignRole('user');
|
||||
|
||||
$credentials = $request->only('email', 'password');
|
||||
if (Auth::attempt($credentials)) {
|
||||
return response()->json(['success' => true, 'message' => 'User created successfully!', 'redirect_url' => route('userLogin')]);
|
||||
}
|
||||
|
||||
|
||||
public static function authenticate(Request $request)
|
||||
{
|
||||
$credentials = $request->validate([
|
||||
'email' => ['required', 'string', 'email', 'max:255'],
|
||||
'password' => ['required', 'string', 'min:8'],
|
||||
]);
|
||||
$remember = $request->has('remember_me') ? true : false;
|
||||
if (Auth::attempt($credentials, $remember)) {
|
||||
$request->session()->regenerate();
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
@ -71,32 +84,12 @@ class AuthenticationController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public static function authenticate(Request $request){
|
||||
$credentials = $request->validate([
|
||||
'email' => ['required', 'string', 'email', 'max:255'],
|
||||
'password' => ['required', 'string', 'min:8'],
|
||||
]);
|
||||
$remember = $request->has('remember_me') ? true : false;
|
||||
if (Auth::attempt($credentials, $remember)) {
|
||||
$request->session()->regenerate();
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'You have successfully logged in!',
|
||||
'redirect_url' => route('home')
|
||||
]);
|
||||
}
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'The provided credentials do not match our records.'
|
||||
]);
|
||||
}
|
||||
|
||||
public static function logout(Request $request){
|
||||
public static function logout(Request $request)
|
||||
{
|
||||
Auth::logout();
|
||||
$request->session()->invalidate();
|
||||
$request->session()->regenerateToken();
|
||||
|
||||
return redirect()->route('userLogin');
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ class NewscategoriesController extends Controller
|
||||
{
|
||||
$this->modelService = new CommonModelService($model);
|
||||
$this->newsCategoriesRepository = $newsCategoriesRepository;
|
||||
|
||||
|
||||
}
|
||||
public function index(Request $request)
|
||||
{
|
||||
|
@ -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,
|
||||
];
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ class User extends Authenticatable
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'phone',
|
||||
'username',
|
||||
'password',
|
||||
];
|
||||
|
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('phone')->nullable()->after('username');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn('phone');
|
||||
});
|
||||
}
|
||||
};
|
@ -12,6 +12,8 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- End Page Banner -->
|
||||
|
||||
<!-- Start Login Area -->
|
||||
@ -19,19 +21,20 @@
|
||||
<div class="container">
|
||||
<div class="login-form">
|
||||
<h2>लगइन फर्म</h2>
|
||||
<form>
|
||||
<form id="login-form" action={{ route('postLogin') }} method="POST">
|
||||
@csrf
|
||||
<div class="form-group">
|
||||
<label>युजरनेम</label>
|
||||
<input type="text" class="form-control" placeholder="युजरनेम">
|
||||
<input type="text" class="form-control" placeholder="युजरनेम" id="email">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>पासवर्ड </label>
|
||||
<input type="text" class="form-control" placeholder="पासवर्ड">
|
||||
<input type="password" class="form-control" placeholder="पासवर्ड" id="password">
|
||||
</div>
|
||||
<div class="row align-items-center">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
<div class="form-check">
|
||||
<input type="checkbox" class="form-check-input" id="checkme">
|
||||
<input type="checkbox" class="form-check-input" id="remember-me">
|
||||
<label class="form-check-label" for="checkme"> याद राख्नुहोस</label>
|
||||
</div>
|
||||
</div>
|
||||
@ -48,7 +51,6 @@
|
||||
</div>
|
||||
</section>
|
||||
@endsection
|
||||
|
||||
@push('js')
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
|
@ -19,9 +19,8 @@
|
||||
<div class="container">
|
||||
<div class="register-form">
|
||||
<h2>रजिस्टर</h2>
|
||||
<form id="register-form" action={{ route('postresgistration') }} method="POST">
|
||||
<form id="register-form" action={{ route('postresgistration') }}>
|
||||
@csrf
|
||||
@method('POST')
|
||||
<div class="form-group">
|
||||
<label>नाम</label>
|
||||
<input type="text" class="form-control" placeholder="नाम" id="name">
|
||||
@ -36,7 +35,7 @@
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>पासवर्ड</label>
|
||||
<input type="text" class="form-control" placeholder="पासवर्ड" id="password">
|
||||
<input type="password" class="form-control" placeholder="पासवर्ड" id="password">
|
||||
</div>
|
||||
<div class="row align-items-center">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
@ -58,51 +57,59 @@
|
||||
|
||||
@push('js')
|
||||
<script>
|
||||
$('#register-form').submit(function(e) {
|
||||
e.preventDefault();
|
||||
let form = $(this);
|
||||
let name = $('#name').val();
|
||||
let email = $('#email').val();
|
||||
let password = $('#password').val();
|
||||
let phone = $('#phone').val();
|
||||
$.ajax({
|
||||
url: form.attr('action'),
|
||||
type: "POST",
|
||||
data: {
|
||||
name: name,
|
||||
email: email,
|
||||
phone: phone,
|
||||
password: password,
|
||||
_token: "{{ csrf_token() }}"
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Success',
|
||||
text: response.message
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
window.location.href = response.redirect_url;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Error',
|
||||
text: response.message
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
let err = JSON.parse(xhr.responseText);
|
||||
$(document).ready(function() {
|
||||
$('#register-form').submit(function(e) {
|
||||
e.preventDefault();
|
||||
let form = $(this);
|
||||
let name = $('#name').val();
|
||||
let email = $('#email').val();
|
||||
let password = $('#password').val();
|
||||
let phone = $('#phone').val();
|
||||
|
||||
$.ajax({
|
||||
url: form.attr('action'),
|
||||
type: "POST",
|
||||
data: {
|
||||
name: name,
|
||||
email: email,
|
||||
phone: phone,
|
||||
password: password,
|
||||
_token: "{{ csrf_token() }}"
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Success',
|
||||
text: response.message
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
window.location.href = response.redirect_url;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Error',
|
||||
text: err.message || 'An error occurred during the request.'
|
||||
text: response.message
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
let err = xhr.responseJSON;
|
||||
let errorMsg = 'An error occurred during the request.';
|
||||
if (err.errors) {
|
||||
errorMsg = Object.values(err.errors).map(errMsg => errMsg.join(', ')).join(' ');
|
||||
}
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Error',
|
||||
text: errorMsg
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@endpush
|
||||
|
@ -66,6 +66,7 @@
|
||||
<script src="{{ asset('hulaki/assets/js/owl.carousel.min.js') }}"></script>
|
||||
<!-- Magnific Popup JS -->
|
||||
<script src="{{ asset('hulaki/assets/js/jquery.magnific-popup.min.js') }}"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
|
||||
<script type="text/javascript"
|
||||
src="https://platform-api.sharethis.com/js/sharethis.js#property=61da909ca3f186001956822c&product=inline-share-buttons"
|
||||
|
@ -40,10 +40,18 @@
|
||||
</a>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<i class='bx bx-user'></i>
|
||||
<a href="{{route('userLogin')}}">लगइन</a>
|
||||
</li>
|
||||
@if (!auth()->check())
|
||||
<li>
|
||||
<i class='bx bx-user'></i>
|
||||
<a href="{{ route('userLogin') }}">लगइन</a>
|
||||
</li>
|
||||
@else
|
||||
<li>
|
||||
<i class='bx bx-user'></i>
|
||||
<a href="#"><span class="fs-10">{{ auth()->user()->name }}</span> </a>
|
||||
<i class='bx bx-power-off'></i>
|
||||
</li>
|
||||
@endif
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@ -56,7 +64,7 @@
|
||||
<div class="main-responsive-nav">
|
||||
<div class="container">
|
||||
<div class="logo">
|
||||
<a href="{{route('home')}}">
|
||||
<a href="{{ route('home') }}">
|
||||
<img src="<?php echo asset(SITEVARS->primary_logo); ?>" class="black-logo" alt="image">
|
||||
<img src="<?php echo asset(SITEVARS->secondary_logo); ?>" class="white-logo" alt="image">
|
||||
</a>
|
||||
@ -66,7 +74,7 @@
|
||||
@if ($ads->isNotEmpty())
|
||||
@foreach ($ads as $ad)
|
||||
@if ($ad->ad_categories_id == 1)
|
||||
<img src="{{ asset($ad->thumb) }}" alt="image">
|
||||
<img src="{{ asset($ad->thumb) }}" alt="image">
|
||||
@endif
|
||||
@endforeach
|
||||
@endif
|
||||
@ -77,7 +85,7 @@
|
||||
<div class="row align-items-center">
|
||||
<div class="col-lg-6">
|
||||
<nav class="navbar navbar-expand-sm navbar-light">
|
||||
<a class="navbar-brand" href="{{route('home')}}">
|
||||
<a class="navbar-brand" href="{{ route('home') }}">
|
||||
<img src="<?php echo asset(SITEVARS->primary_logo); ?>" class="black-logo" alt="image"
|
||||
style="margin-left: -20px;max-width: 350px; height: auto; display: block;">
|
||||
<img src="<?php echo asset(SITEVARS->secondary_logo); ?>" class="white-logo" alt="image" style="margin-left: -20px;">
|
||||
|
@ -12,9 +12,9 @@ use App\Http\Controllers\Auth\VerifyEmailController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::middleware('guest')->group(function () {
|
||||
// Route::get('register', [RegisteredUserController::class, 'create'])->name('register');
|
||||
Route::get('register', [RegisteredUserController::class, 'create'])->name('register');
|
||||
|
||||
// Route::post('register', [RegisteredUserController::class, 'store']);
|
||||
Route::post('register', [RegisteredUserController::class, 'store'])->name('register.store');
|
||||
|
||||
Route::get('login', [AuthenticatedSessionController::class, 'create'])
|
||||
->name('login');
|
||||
|
Loading…
x
Reference in New Issue
Block a user