app/Http/Controllers/dashboard/admin/SubjectsController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(Request $request)
    {
        $request->validate($this->rules);
        $data = [
            "name" => $request->post('name'),
            "code" => strtoupper($request->post('code')),
            "days" => $request->post('days'),
            "start_at" => $request->post('start_at'),
            "end_at" => $request->post('end_at'),
            "teacher_id" => $request->post('teacher_id'),
            "classroom_id" => $request->post('classroom_id')
        ];
        $response = new Subjects($data);
        if (!$response->save()) return $this->status();
        return $this->status('success', "success add new subject");
    }
public function store ( Request $ request ) { $ request -> validate ( $ this -> rules ) ; $ data = [ " name " => $ request -> post ( 'name' ) , " code " => strtoupper ( $ request -> post ( 'code' ) ) , " days " => $ request -> post ( 'days' ) , " start_at " => $ request -> post ( 'start_at' ) , " end_at " => $ request -> post ( 'end_at' ) , " teacher_id " => $ request -> post ( 'teacher_id' ) , " classroom_id " => $ request -> post ( 'classroom_id' ) ] ; $ response = new Subjects ( $ data ) ; if ( ! $ response -> save ( ) ) return $ this -> status ( ) ; return $ this -> status ( 'success' , " success add new subject " ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
// dd($data);