app/Http/Controllers/dashboard/admin/SubjectsController.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, Subjects $subject)
    {
        $this->rules['code'] = ["required",  Rule::unique('subjects')->ignore($subject->id)];
        $request->validate($this->rules);
        $data = [
            "name" => $request->post('name'),
            "code" => strtoupper($request->post('code')),
            "teacher_id" => $request->post('teacher_id'),
            "days" => $request->post('days'),
            "start_at" => $request->post('start_at'),
            "end_at" => $request->post('end_at'),
            "classroom_id" => $request->post('classroom_id')
        ];
        $response = $subject->update($data);
        if (!$response) return $this->status();
        return $this->status('success', "success updated subject");
    }
public function update ( Request $ request , Subjects $ subject ) { $ this -> rules [ 'code' ] = [ " required " , Rule :: unique ( 'subjects' ) -> ignore ( $ subject -> id ) ] ; $ request -> validate ( $ this -> rules ) ; $ data = [ " name " => $ request -> post ( 'name' ) , " code " => strtoupper ( $ request -> post ( 'code' ) ) , " teacher_id " => $ request -> post ( 'teacher_id' ) , " days " => $ request -> post ( 'days' ) , " start_at " => $ request -> post ( 'start_at' ) , " end_at " => $ request -> post ( 'end_at' ) , " classroom_id " => $ request -> post ( 'classroom_id' ) ] ; $ response = $ subject -> update ( $ data ) ; if ( ! $ response ) return $ this -> status ( ) ; return $ this -> status ( 'success' , " success updated subject " ) ; }
Update the specified resource in storage.
Update the specified resource in storage .