app/Http/Controllers/dashboard/admin/StudentsController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, Students $student)
    {
        $this->rules['phone'] = ['nullable', "min:12", "numeric", Rule::unique('students')->ignore($student->id)];
        $this->rules['student_id'] = ['required', Rule::unique('students')->ignore($student->id)];
        $request->validate($this->rules);
        $data = [
            "firstname" => $request->post('firstname'),
            "lastname" => $request->post('lastname'),
            "classroom_id" => $request->post('classroom_id'),
            "birthday" => $request->post('birthday'),
            "city" => $request->post('city'),
            "phone" => $request->post('phone'),
            "province" => $request->post('province'),
            "country" => $request->post('country'),
            "address" => $request->post('address'),
            "status" => $request->post('status'),
            "reason" => $request->post('reason')
        ];
        $response =  $student->update($data);
        if (!$response) return $this->status();
        return $this->status("success", "success update student");
    }
public function update ( Request $ request , Students $ student ) { $ this -> rules [ 'phone' ] = [ 'nullable' , " min:12 " , " numeric " , Rule :: unique ( 'students' ) -> ignore ( $ student -> id ) ] ; $ this -> rules [ 'student_id' ] = [ 'required' , Rule :: unique ( 'students' ) -> ignore ( $ student -> id ) ] ; $ request -> validate ( $ this -> rules ) ; $ data = [ " firstname " => $ request -> post ( 'firstname' ) , " lastname " => $ request -> post ( 'lastname' ) , " classroom_id " => $ request -> post ( 'classroom_id' ) , " birthday " => $ request -> post ( 'birthday' ) , " city " => $ request -> post ( 'city' ) , " phone " => $ request -> post ( 'phone' ) , " province " => $ request -> post ( 'province' ) , " country " => $ request -> post ( 'country' ) , " address " => $ request -> post ( 'address' ) , " status " => $ request -> post ( 'status' ) , " reason " => $ request -> post ( 'reason' ) ] ; $ response = $ student -> update ( $ data ) ; if ( ! $ response ) return $ this -> status ( ) ; return $ this -> status ( " success " , " success update student " ) ; }
Update the specified resource in storage.
Update the specified resource in storage .