app/Http/Controllers/dashboard/admin/TeachersController.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)
    {
        $this->rules['user_id'] =  ["unique:teachers", 'required'];
        $request->validate($this->rules);
        $data = [
            "teacher_id" => $request->post('teacher_id'),
            "user_id" => $request->post('user_id'),
            "firstname" => $request->post('firstname'),
            "lastname" => $request->post('lastname'),
            "phone" => $request->post('phone'),
            "address" => $request->post('address'),
            "degree" => $request->post('degree'),
            "status" => $request->post('status'),
            "reason" => $request->post('reason')
        ];
        $response = new Teachers($data);
        if (!$response->save()) return $this->status();
        return $this->status('success', "success add new teacher");
    }
public function store ( Request $ request ) { $ this -> rules [ 'user_id' ] = [ " unique:teachers " , 'required' ] ; $ request -> validate ( $ this -> rules ) ; $ data = [ " teacher_id " => $ request -> post ( 'teacher_id' ) , " user_id " => $ request -> post ( 'user_id' ) , " firstname " => $ request -> post ( 'firstname' ) , " lastname " => $ request -> post ( 'lastname' ) , " phone " => $ request -> post ( 'phone' ) , " address " => $ request -> post ( 'address' ) , " degree " => $ request -> post ( 'degree' ) , " status " => $ request -> post ( 'status' ) , " reason " => $ request -> post ( 'reason' ) ] ; $ response = new Teachers ( $ data ) ; if ( ! $ response -> save ( ) ) return $ this -> status ( ) ; return $ this -> status ( 'success' , " success add new teacher " ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .