app/Http/Controllers/dashboard/students/StudentsProfileController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Models\Students  $students
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, Students $student)
    {
        $request->validate([
            "firstname" => ["required"],
            "lastname" => ["required"],
            "phone" => ['nullable', "min:12", "numeric", Rule::unique('students')->ignore($student->id)],
        ]);
        $data = [
            "firstname" => $request->post('firstname'),
            "lastname" => $request->post('lastname'),
            "phone" => $request->post('phone'),
            "birthday" => $request->post('birthday'),
            "address" => $request->post('address'),
            "city" => $request->post('city'),
            "province" => $request->post('province'),
            "country" => $request->post('country'),
        ];
        $response = $student->update($data);
        if (!$response) return back()->with('error', "Try Again");
        return redirect(route('profile.index'))->with('success', 'success update profile');
    }
public function update ( Request $ request , Students $ student ) { $ request -> validate ( [ " firstname " => [ " required " ] , " lastname " => [ " required " ] , " phone " => [ 'nullable' , " min:12 " , " numeric " , Rule :: unique ( 'students' ) -> ignore ( $ student -> id ) ] , ] ) ; $ data = [ " firstname " => $ request -> post ( 'firstname' ) , " lastname " => $ request -> post ( 'lastname' ) , " phone " => $ request -> post ( 'phone' ) , " birthday " => $ request -> post ( 'birthday' ) , " address " => $ request -> post ( 'address' ) , " city " => $ request -> post ( 'city' ) , " province " => $ request -> post ( 'province' ) , " country " => $ request -> post ( 'country' ) , ] ; $ response = $ student -> update ( $ data ) ; if ( ! $ response ) return back ( ) -> with ( 'error' , " Try Again " ) ; return redirect ( route ( 'profile.index' ) ) -> with ( 'success' , 'success update profile' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .