64 lines
2.5 KiB
PHP
64 lines
2.5 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Http\Controllers\WEB;
|
||
|
|
|
||
|
|
use App\Http\Controllers\Controller;
|
||
|
|
use Illuminate\Http\Request;
|
||
|
|
use Illuminate\Support\Facades\Hash;
|
||
|
|
use Modules\Frontend\Models\Onboarding;
|
||
|
|
|
||
|
|
class PublicOnboardingController extends Controller
|
||
|
|
{
|
||
|
|
public function create()
|
||
|
|
{
|
||
|
|
return view('public.onboarding.create');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function store(Request $request)
|
||
|
|
{
|
||
|
|
$request->validate([
|
||
|
|
'restaurant_name' => 'required|string|max:100',
|
||
|
|
'restaurant_email' => 'required|email|max:255|unique:restaurants,email',
|
||
|
|
'restaurant_phone' => 'required|string|max:15|unique:restaurants,phone',
|
||
|
|
'restaurant_domain' => 'nullable|string|max:100|unique:restaurants,domain',
|
||
|
|
'restaurant_type' => 'nullable|string|max:100',
|
||
|
|
'restaurant_address' => 'nullable|string|max:255',
|
||
|
|
'restaurant_logo' => 'nullable|image|mimes:jpeg,png,jpg,gif|max:2048',
|
||
|
|
'name' => 'required|string|max:100',
|
||
|
|
'email' => 'required|email|max:255|unique:users,email',
|
||
|
|
'phone' => 'required|string|max:50',
|
||
|
|
'password' => 'required|string|min:4|confirmed',
|
||
|
|
'avatar' => 'nullable|image|mimes:jpeg,png,jpg,gif|max:2048',
|
||
|
|
]);
|
||
|
|
|
||
|
|
// Handle the restaurant_logo file upload if it exists
|
||
|
|
$restaurantLogoPath = $request->hasFile('restaurant_logo')
|
||
|
|
? fileUploader('restaurants/', 'png', $request->file('restaurant_logo'))
|
||
|
|
: null;
|
||
|
|
|
||
|
|
// Handle the user_avatar file upload if it exists
|
||
|
|
$userAvatarPath = $request->hasFile('avatar')
|
||
|
|
? fileUploader('user_avatars/', 'png', $request->file('avatar'))
|
||
|
|
: null;
|
||
|
|
|
||
|
|
// Save onboarding data
|
||
|
|
Onboarding::create([
|
||
|
|
'restaurant_name' => $request->restaurant_name,
|
||
|
|
'restaurant_email' => $request->restaurant_email,
|
||
|
|
'restaurant_phone' => $request->restaurant_phone,
|
||
|
|
'restaurant_domain' => $request->restaurant_domain,
|
||
|
|
'restaurant_type' => $request->restaurant_type,
|
||
|
|
'restaurant_address' => $request->restaurant_address,
|
||
|
|
'name' => $request->name,
|
||
|
|
'email' => $request->email,
|
||
|
|
'phone' => $request->phone,
|
||
|
|
'password' => Hash::make($request->password),
|
||
|
|
'restaurant_logo' => $restaurantLogoPath,
|
||
|
|
'user_avatar' => $userAvatarPath,
|
||
|
|
'status' => 'pending',
|
||
|
|
]);
|
||
|
|
|
||
|
|
return redirect()->back()->with('success', 'Your onboarding request has been submitted successfully!');
|
||
|
|
}
|
||
|
|
}
|