@@ -1,69 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\APIs\RestaurantApi;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\APIs\RestaurantService\RestAuthApiService;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class RestAuthApiController extends Controller
|
||||
{
|
||||
protected $RestAuthApiService;
|
||||
|
||||
public function __construct(RestAuthApiService $RestAuthApiService)
|
||||
{
|
||||
$this->RestAuthApiService = $RestAuthApiService;
|
||||
}
|
||||
|
||||
public function viewresyaurant()
|
||||
{
|
||||
try {
|
||||
$response = $this->RestAuthApiService->viewresyaurant();
|
||||
return jsonResponseWithSuccessMessageApi(__('success.data_fetched_successfully'), $response, 200);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('FAW get data controller function failed: ' . $e->getMessage());
|
||||
return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function restRegister(Request $request)
|
||||
{
|
||||
try {
|
||||
$validator = Validator::make($request->all(), [
|
||||
'first_name' => 'required|string|min:2|max:100',
|
||||
'last_name' => 'required|string|min:2|max:100',
|
||||
'role' => 'required|string|min:2|max:100',
|
||||
'restaurant_xid' => 'required',
|
||||
'date_of_birth' => 'required|date',
|
||||
'email_address' => [
|
||||
'required',
|
||||
'string',
|
||||
'email',
|
||||
'max:100',
|
||||
Rule::unique('iam_principal')->where(function ($query) {
|
||||
return $query->where('principal_type_xid', 4)->whereNull('deleted_at');
|
||||
}),
|
||||
],
|
||||
'phone_number' => 'required|min:10',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
$validationErrors = $validator->errors()->all();
|
||||
Log::error("Registration validation error: " . implode(", ", $validationErrors));
|
||||
return jsonResponseWithErrorMessageApi($validationErrors, 403);
|
||||
}
|
||||
return $this->RestAuthApiService->restRegister($request);
|
||||
} catch (\Exception $ex) {
|
||||
Log::error("Registration API Failed: " . $ex->getMessage());
|
||||
return jsonResponseWithErrorMessage(__('error_message.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\APIs\RestaurantApi;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\APIs\RestaurantService\RestAuthApiService;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\Rule;
|
||||
use App\Models\IamPrincipal;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class RestAuthApiController extends Controller
|
||||
{
|
||||
protected $RestAuthApiService;
|
||||
|
||||
public function __construct(RestAuthApiService $RestAuthApiService)
|
||||
{
|
||||
$this->RestAuthApiService = $RestAuthApiService;
|
||||
}
|
||||
|
||||
public function viewresyaurant()
|
||||
{
|
||||
try {
|
||||
$response = $this->RestAuthApiService->viewresyaurant();
|
||||
// dd( $response);
|
||||
return jsonResponseWithSuccessMessageApi(__('success.data_fetched_successfully'), $response, 200);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('FAW get data controller function failed: ' . $e->getMessage());
|
||||
return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function restRegister(Request $request)
|
||||
{
|
||||
try {
|
||||
$validator = Validator::make($request->all(), [
|
||||
'first_name' => 'required|string|min:2|max:100',
|
||||
'last_name' => 'required|string|min:2|max:100',
|
||||
'role' => 'required|string|min:2|max:100',
|
||||
'restaurant_xid' => 'required',
|
||||
'date_of_birth' => 'required|date',
|
||||
'email_address' => [
|
||||
'required',
|
||||
'string',
|
||||
'email',
|
||||
'max:100',
|
||||
Rule::unique('iam_principal')->where(function ($query) {
|
||||
return $query->where('principal_type_xid', 4)->whereNull('deleted_at');
|
||||
}),
|
||||
],
|
||||
'phone_number' => 'required|min:10',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
$validationErrors = $validator->errors()->all();
|
||||
Log::error("Registration validation error: " . implode(", ", $validationErrors));
|
||||
return jsonResponseWithErrorMessageApi($validationErrors, 403);
|
||||
}
|
||||
return $this->RestAuthApiService->restRegister($request);
|
||||
} catch (\Exception $ex) {
|
||||
Log::error("Registration API Failed: " . $ex->getMessage());
|
||||
return jsonResponseWithErrorMessage(__('error_message.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
try {
|
||||
$validator = Validator::make($request->all(), [
|
||||
'email_address' => 'required|string|email',
|
||||
'password' => 'required|string|min:6',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
$validationErrors = $validator->errors()->all();
|
||||
Log::error("Login validation error: " . implode(", ", $validationErrors));
|
||||
return jsonResponseWithErrorMessageApi($validationErrors, 403);
|
||||
}
|
||||
return $this->RestAuthApiService->login($request);
|
||||
} catch (\Exception $ex) {
|
||||
Log::error("Login API Failed: " . $ex->getMessage());
|
||||
return jsonResponseWithErrorMessage(__('error_message.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
public function restForgotPassword(Request $request)
|
||||
{
|
||||
try {
|
||||
$validator = Validator::make($request->all(), [
|
||||
'email_address' => [
|
||||
'required',
|
||||
'string',
|
||||
'email',
|
||||
function ($attribute, $value, $fail) {
|
||||
$existingUser = IamPrincipal::where('email_address', $value)->where('principal_type_xid', 4)->whereNull('deleted_at')->exists();
|
||||
if (!$existingUser) {
|
||||
$fail('The selected email address is invalid.');
|
||||
}
|
||||
},
|
||||
],
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
$validationErrors = $validator->errors()->all();
|
||||
Log::error("Forgot password validation error: " . implode(", ", $validationErrors));
|
||||
|
||||
return jsonResponseWithErrorMessageApi($validationErrors, 403);
|
||||
}
|
||||
return $this->RestAuthApiService->restForgotPassword($request);
|
||||
} catch (\Exception $ex) {
|
||||
Log::error("Forgot password API Failed: " . $ex->getMessage());
|
||||
return jsonResponseWithErrorMessage(__('error_message.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function restVerifyOTP(Request $request)
|
||||
{
|
||||
try {
|
||||
$validator = Validator::make($request->all(), [
|
||||
'email_address' => [
|
||||
'required',
|
||||
'string',
|
||||
'email',
|
||||
function ($attribute, $value, $fail) {
|
||||
$existingUser = IamPrincipal::where('email_address', $value)->where('principal_type_xid', 4)->whereNull('deleted_at')->exists();
|
||||
if (!$existingUser) {
|
||||
$fail('The selected email address is invalid.');
|
||||
}
|
||||
},
|
||||
],
|
||||
'otp' => 'required',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
$validationErrors = $validator->errors()->all();
|
||||
Log::error("Forgot password validation error: " . implode(", ", $validationErrors));
|
||||
return jsonResponseWithErrorMessageApi($validationErrors, 403);
|
||||
}
|
||||
return $this->RestAuthApiService->restVerifyOTP($request);
|
||||
} catch (\Exception $ex) {
|
||||
Log::error("Verify password API Failed: " . $ex->getMessage());
|
||||
return jsonResponseWithErrorMessage(__('error_message.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
public function restChangePassword(Request $request)
|
||||
{
|
||||
try {
|
||||
$validator = Validator::make($request->all(), [
|
||||
'iam_principal_xid' => 'required|exists:iam_principal,id',
|
||||
'password' => 'required|confirmed',
|
||||
]);
|
||||
if ($validator->fails()) {
|
||||
$validationErrors = $validator->errors()->all();
|
||||
Log::error("Forgot password validation error: " . implode(", ", $validationErrors));
|
||||
return jsonResponseWithErrorMessageApi($validationErrors, 403);
|
||||
}
|
||||
$response = $this->RestAuthApiService->restChangePassword($request);
|
||||
return jsonResponseWithSuccessMessage(__('auth.data_fetched_successfully'), $response, 200);
|
||||
} catch (\Exception $ex) {
|
||||
Log::error("Change password API Failed: " . $ex->getMessage());
|
||||
return jsonResponseWithErrorMessage(__('error_message.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
public function restResendOtp(Request $request)
|
||||
{
|
||||
try {
|
||||
$validator = Validator::make($request->all(), [
|
||||
'iam_principal_xid' => 'required|exists:iam_principal,id',
|
||||
'otp_purpose' => 'required'
|
||||
]);
|
||||
if ($validator->fails()) {
|
||||
$validationErrors = $validator->errors()->all();
|
||||
Log::error("Forgot password validation error: " . implode(", ", $validationErrors));
|
||||
return jsonResponseWithErrorMessageApi($validationErrors, 403);
|
||||
}
|
||||
return $this->RestAuthApiService->restResendOtp($request);
|
||||
} catch (\Exception $ex) {
|
||||
Log::error("Resend otp API Failed: " . $ex->getMessage());
|
||||
return jsonResponseWithErrorMessage(__('error_message.something_went_wrong'), 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -83,6 +83,7 @@ class DashboardController extends Controller
|
||||
->orderBy(DB::raw("MONTH(created_at)"))
|
||||
->pluck('count', 'month')
|
||||
->toArray();
|
||||
// dd($dataMonthlyWithType3);
|
||||
|
||||
$dataMonthlyWithType4 = IamPrincipal::select(DB::raw("COUNT(*) as count"), DB::raw("MONTH(created_at) as month"))
|
||||
->whereIn('principal_type_xid', [4])
|
||||
|
||||
@@ -14,14 +14,7 @@ use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class ManageProfileController extends Controller
|
||||
{
|
||||
// public function index(){
|
||||
|
||||
// // $get_user = Auth::guard('admin')->user();
|
||||
// // dd($get_user);
|
||||
// // $user = IamPrincipal::find($get_user->id);
|
||||
// $user = IamPrincipal::find(1);
|
||||
// return view('Admin.pages.manage_profile.manage_profile',compact('user'));
|
||||
// }
|
||||
|
||||
public function index()
|
||||
{
|
||||
$get_user = Auth::guard('admin')->user();
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Services\APIs\RestaurantService;
|
||||
|
||||
use App\Models\admin\ManageRestaurant;
|
||||
use App\Models\admin\ManageVoucherModel;
|
||||
use App\Models\ManageRestaurant;
|
||||
use App\Models\ManageVoucherModel;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Models\IamPrincipal;
|
||||
@@ -23,7 +23,7 @@ class RestAuthApiService
|
||||
public function viewresyaurant()
|
||||
{
|
||||
try {
|
||||
$data = ManageVoucherModel::select('id', 'coupon_name')->where('is_active', 1)->get()->toArray();
|
||||
$data = ManageRestaurant::select('id', 'name','description','restaurant_id','address','image','bio','try_on_1','try_on_2','try_on_3','try_on_4','exclusion','latitude','longtitude')->where('is_active', 1)->get()->toArray();
|
||||
return $data;
|
||||
} catch (Exception $ex) {
|
||||
DB::rollBack();
|
||||
@@ -33,59 +33,59 @@ class RestAuthApiService
|
||||
}
|
||||
|
||||
|
||||
public function restRegister($request)
|
||||
{
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
$restaurantId = $request->input('restaurant_xid');
|
||||
// public function restRegister($request)
|
||||
// {
|
||||
// try {
|
||||
// DB::beginTransaction();
|
||||
// $restaurantId = $request->input('restaurant_xid');
|
||||
|
||||
// Fetch the restaurant details based on the selected restaurantId
|
||||
$selectedRestaurant = ManageVoucherModel::find($restaurantId);
|
||||
// // Fetch the restaurant details based on the selected restaurantId
|
||||
// $selectedRestaurant = ManageVoucherModel::find($restaurantId);
|
||||
|
||||
if (!$selectedRestaurant) {
|
||||
return jsonResponseWithErrorMessageApi(__('auth.restaurant_data_not_found'), 403);
|
||||
}
|
||||
// if (!$selectedRestaurant) {
|
||||
// return jsonResponseWithErrorMessageApi(__('auth.restaurant_data_not_found'), 403);
|
||||
// }
|
||||
|
||||
// Create a new restaurant user record
|
||||
$restaurantuser = IamPrincipal::create([
|
||||
'one_signal_player_id' => $request->one_signal_player_id,
|
||||
'first_name' => $request->first_name,
|
||||
'last_name' => $request->last_name,
|
||||
'email_address' => $request->email_address,
|
||||
// 'password' => Hash::make('Cheers@123'),
|
||||
'principal_type_xid' => 4, //4 for restaurant
|
||||
'principal_source_xid' => 2, //2 for mobile
|
||||
'phone_number' => $request->phone_number,
|
||||
'date_of_birth' => $request->date_of_birth,
|
||||
'is_active' => '0',
|
||||
]);
|
||||
// // Create a new restaurant user record
|
||||
// $restaurantuser = IamPrincipal::create([
|
||||
// 'one_signal_player_id' => $request->one_signal_player_id,
|
||||
// 'first_name' => $request->first_name,
|
||||
// 'last_name' => $request->last_name,
|
||||
// 'email_address' => $request->email_address,
|
||||
// // 'password' => Hash::make('Cheers@123'),
|
||||
// 'principal_type_xid' => 4, //4 for restaurant
|
||||
// 'principal_source_xid' => 2, //2 for mobile
|
||||
// 'phone_number' => $request->phone_number,
|
||||
// 'date_of_birth' => $request->date_of_birth,
|
||||
// 'is_active' => '0',
|
||||
// ]);
|
||||
|
||||
$restaurantUserRole = IamPrincipalRestaurantRole::create([
|
||||
'principal_xid' => $restaurantuser->id,
|
||||
'role' => $request->role,
|
||||
'restaurant_xid' => $restaurantId,
|
||||
]);
|
||||
// $restaurantUserRole = IamPrincipalRestaurantRole::create([
|
||||
// 'principal_xid' => $restaurantuser->id,
|
||||
// 'role' => $request->role,
|
||||
// 'restaurant_xid' => $restaurantId,
|
||||
// ]);
|
||||
|
||||
DB::commit();
|
||||
// DB::commit();
|
||||
|
||||
// $token = auth()->login($restaurantuser);
|
||||
// // $token = auth()->login($restaurantuser);
|
||||
|
||||
// Return response with user details, access token, and status
|
||||
$response = [
|
||||
'user' => $restaurantuser,
|
||||
// 'restaurant_details' => $restaurantId,
|
||||
// 'access_token' => $token,
|
||||
'token_type' => 'bearer',
|
||||
'status' => 'Your request has been sent. Kindly check your email.'
|
||||
];
|
||||
return jsonResponseWithSuccessMessage(__('auth.Rest_user_created'), $response, 200);
|
||||
} catch (QueryException $e) {
|
||||
// Rollback transaction in case of an error
|
||||
DB::rollBack();
|
||||
Log::error('Restaurant Registration Failed ' . $e->getMessage());
|
||||
return jsonResponseWithErrorMessageApi(__('auth.authentication_failed'), 403);
|
||||
}
|
||||
}
|
||||
// // Return response with user details, access token, and status
|
||||
// $response = [
|
||||
// 'user' => $restaurantuser,
|
||||
// // 'restaurant_details' => $restaurantId,
|
||||
// // 'access_token' => $token,
|
||||
// 'token_type' => 'bearer',
|
||||
// 'status' => 'Your request has been sent. Kindly check your email.'
|
||||
// ];
|
||||
// return jsonResponseWithSuccessMessage(__('auth.Rest_user_created'), $response, 200);
|
||||
// } catch (QueryException $e) {
|
||||
// // Rollback transaction in case of an error
|
||||
// DB::rollBack();
|
||||
// Log::error('Restaurant Registration Failed ' . $e->getMessage());
|
||||
// return jsonResponseWithErrorMessageApi(__('auth.authentication_failed'), 403);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
public function login($request)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\APIs\RestaurantService;
|
||||
use App\Services\APIs\RestaurantService\RestAuthApiService;
|
||||
|
||||
use App\Models\admin\ManageRestaurant;
|
||||
use App\Models\ManageRestaurant;
|
||||
use App\Models\admin\ManageVoucherModel;
|
||||
use App\Models\IamPrincipal;
|
||||
use App\Models\IamPrincipalRestaurantRole;
|
||||
|
||||
@@ -149,7 +149,7 @@
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5 class="text-start">Locations</h5>
|
||||
<img src="../src/assets/img/map.svg" width="100%" height="173px" alt="">
|
||||
<img src="{{ asset('public/assets/img/map.svg')}}" width="100%" height="173px" alt="">
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@@ -11,7 +11,10 @@ use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::middleware(['restaurantApiBasicAuth'])->group(function () {
|
||||
// Define your routes here
|
||||
Route::get('/v1/list-restaurant', [RestAuthApiController::class, 'viewresyaurant']);
|
||||
// Route::get('/v1/list-restaurant', [RestAuthApiController::class, 'viewresyaurant']);
|
||||
// In routes/api.php
|
||||
Route::get('/v1/list-restaurant', [RestAuthApiController::class, 'viewResyaurant']);
|
||||
|
||||
Route::post('/v1/rest-register', [RestAuthApiController::class, 'restRegister']);
|
||||
Route::post('/v1/rest-login', [RestAuthApiController::class, 'login']);
|
||||
Route::post('/v1/rest-forgot-password', [RestAuthApiController::class, 'restForgotPassword']);
|
||||
|
||||
Reference in New Issue
Block a user