اذهب إلى المحتوى

Majd Aust

الأعضاء
  • المساهمات

    4
  • تاريخ الانضمام

  • تاريخ آخر زيارة

كل منشورات العضو Majd Aust

  1. <?php namespace App\Http\Controllers\Auth; use App\Http\Controllers\Controller; use App\Models\User; use Illuminate\Auth\Events\Registered; use Illuminate\Http\Request; use Illuminate\Http\Response; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Hash; use Illuminate\Validation\Rules; use Illuminate\Validation\Rules\Password; class RegisteredUserController extends Controller { /** * Handle an incoming registration request. * * @throws \Illuminate\Validation\ValidationException */ public function store(Request $request): Response { $request->validate([ 'name' => ['required', 'string', 'max:255'], 'email' => ['required', 'string', 'lowercase', 'email', 'max:255', 'unique:'.User::class], 'password' => ['required', 'confirmed', Password::defaults()], ]); $user = User::create([ 'name' => $request->name, 'email' => $request->email, 'password' => $request->password, ]); event(new Registered($user)); Auth::login($user); return response()->noContent(); } } ما زال الخطأ موجود
  2. نسيت أن أذكر أن الحقول تلك غير ضرورية nullable و الخطأ يحدث أيضا عند استخدام API
  3. <div className='dark:bg-darkbg py-10 flex justify-center items-center'> <form method='POST' action='http://127.0.0.1:8000/register' className='bg-red-500 text-bluePrime font-bold flex flex-col gap-5'> <input onChange={(e) => setName(e.target.value)} type="text" name='name' placeholder="Name" /> <input onChange={(e) => setemail(e.target.value)} type="email" name='email' placeholder="Email" /> <input onChange={(e) => setpassword(e.target.value)} type="password" name='password' placeholder="Password" /> <button type="submit" className='p-8 bg-black text-white'>Register</button> </form> </div> و الخطأ الذي يجدث هو كود 302
  4. السلام عليكم و رحمة الله و بركاته كنت اعمل على مشروع مع زميلي بالفريق الذي يستعمل Next Js و كنت استعمل Laravel لكن المشروع كان يعمل و سبق و رفعناه على ال Server ولكن ملف AuthController لا ينشء مستخدمين على جهاز المطور ها هو الكود خاصتي الذي لا عاد يعمل فجأة <?php namespace App\Http\Controllers; use App\Models\User; use App\Models\NormalUser; use Illuminate\Http\Request; use Illuminate\Validation\Rule; use App\Http\Requests\LoginRequest; use App\Http\Resources\UserResource; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Hash; use App\Http\Requests\RegisterRequest; use Illuminate\Auth\Events\Registered; class AuthController extends Controller { public function register(Request $request) { $incomingFields = $request->validate([ 'name' => ['required', 'min:2', 'max:10', Rule::unique('normal_users', 'name'), 'alpha'], 'lName' => ['required', 'min:2', 'max:10', Rule::unique('normal_users', 'lName'), 'alpha'], 'email' => ['required', 'email', Rule::unique('normal_users', 'email')], 'password' => ['required', 'min:10', 'max:200'], 'occupation' => ['required'], 'gender' => ['required'], 'birthday' => ['required'] ]); $incomingFields['password'] = bcrypt($incomingFields['password']); // if($request->hasFile('image')){ // $incomingFields['image'] = $request->file('image')->store('images','public'); // } $user = NormalUser::create($incomingFields); event(new Registered($user)); return redirect('http://localhost:3000/'); } // login a user method public function login(Request $request) { $incomingFields = $request->validate([ 'loginemail' => 'required', 'loginpassword' => 'required' ]); $credentials = [ 'email' => $request->loginemail, 'password' => $request->loginpassword ]; if (Auth::guard('NormalUser')->attempt($credentials)) { return redirect('http://localhost:3000/'); } else { return redirect('http://localhost:3000/signinfalse'); } } // get the authenticated user method public function user($id) { $user = User::find($id); return response()->json($user); } public function show(Request $request) { $user = NormalUser::where('email', $request->email)->first(); if ($user) { return response()->json([ 'status' => true, 'message' => 'User found successfully.', 'data' => $user ]); } else { return response()->json([ 'status' => false, 'message' => 'User not found.', ]); } } public function editUser(Request $request) { // Retrieve the authenticated user $user = NormalUser::where('email', $request->email)->first(); // Validate the incoming request $request->validate([ 'image' => 'image|mimes:jpeg,png,jpg,gif,svg|max:2048', ]); // Check if a new image file was uploaded if ($request->hasFile('image')) { // Get the new image file $image = $request->file('image'); // Generate a unique filename for the new image $filename = uniqid() . '.' . $image->getClientOriginalExtension(); // Move the new image file to the public/storage directory $image->storeAs('public/storage', $filename); // Update the user's image field with the new filename $user->image = $filename; } // Save the updated user to the database $user->save(); // Return a response indicating success return response()->json([ 'status' => true, 'message' => 'User updated successfully.', ]); } // public function editUser(Request $request){ // } public function data(Request $request) { $user = NormalUser::where('email', $request->email)->first(); if ($user) { return response()->json($user); } else { return response()->json([ 'status' => false, 'message' => 'User not found.', ]); } } public function edit(Request $request) { $user = NormalUser::where('email', $request->email)->first(); $incomingFields = $request->about; $user->about = $incomingFields; $user->save(); } } شكرا جزيلا اخوتي
×
×
  • أضف...