app/Http/Controllers/dashboard/admin/TeachersController.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, Teachers $teacher)
    {
        $this->rules['phone'] = ['nullable', "min:12", "numeric", Rule::unique('teachers')->ignore($teacher->id)];
        $request->validate($this->rules);
        $data = [
            "teacher_id" => $request->post('teacher_id'),
            "firstname" => $request->post('firstname'),
            "lastname" => $request->post('lastname'),
            "address" => $request->post('address'),
            "degree" => $request->post('degree'),
            "status" => $request->post('status'),
            "reason" => $request->post('reason')
        ];
        $response = $teacher->update($data);
        if (!$response) return $this->status();
        return $this->status('success', "success updated teacher");
    }
public function update ( Request $ request , Teachers $ teacher ) { $ this -> rules [ 'phone' ] = [ 'nullable' , " min:12 " , " numeric " , Rule :: unique ( 'teachers' ) -> ignore ( $ teacher -> id ) ] ; $ request -> validate ( $ this -> rules ) ; $ data = [ " teacher_id " => $ request -> post ( 'teacher_id' ) , " firstname " => $ request -> post ( 'firstname' ) , " lastname " => $ request -> post ( 'lastname' ) , " address " => $ request -> post ( 'address' ) , " degree " => $ request -> post ( 'degree' ) , " status " => $ request -> post ( 'status' ) , " reason " => $ request -> post ( 'reason' ) ] ; $ response = $ teacher -> update ( $ data ) ; if ( ! $ response ) return $ this -> status ( ) ; return $ this -> status ( 'success' , " success updated teacher " ) ; }
Update the specified resource in storage.
Update the specified resource in storage .