app/Http/Controllers/dashboard/admin/ClassroomsController.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, Classrooms $classroom)
    {
        $this->rules = [];
        $this->rules['name'] = ["required", Rule::unique('classrooms')->ignore($classroom->id)];
        $this->rules['grade_id'] = ["required"];
        $request->validate($this->rules);
        $response = $classroom->update(array('name' => $request->post('name'), "grade_id" => $request->post('grade_id')));
        if (!$response) return $this->status();
        return $this->status('success', 'success update classroom');
    }
public function update ( Request $ request , Classrooms $ classroom ) { $ this -> rules = [ ] ; $ this -> rules [ 'name' ] = [ " required " , Rule :: unique ( 'classrooms' ) -> ignore ( $ classroom -> id ) ] ; $ this -> rules [ 'grade_id' ] = [ " required " ] ; $ request -> validate ( $ this -> rules ) ; $ response = $ classroom -> update ( array ( 'name' => $ request -> post ( 'name' ) , " grade_id " => $ request -> post ( 'grade_id' ) ) ) ; if ( ! $ response ) return $ this -> status ( ) ; return $ this -> status ( 'success' , 'success update classroom' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .