app/Http/Controllers/JobManagerController.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->validate($request ,[
            'name' => 'required|max:200',
            'job_type_id' => 'required|numeric',
            'job_cate_id' => 'array',
            'job_level_id' => 'array',
            'image' => 'required|max:200',
            'time_start' => 'required|date',
            'time_to' => 'required|date',
            'slug' => 'required|max:200',
            'company_id' => 'required|numeric',
            'country_id' => 'required|numeric',
            'description' => 'required',
            'salary' => 'required|max:200',
            'contentInfo' =>'required'
        ]);
        $newJob = new Job();
        $newJob->setData($request);
        $newJob->save();
        if(isset($request->job_cate_id)) {
            $newJob->jobCates()->sync($request->job_cate_id);
        } else {
            $newJob->jobCates()->sync(array());
        }
        if(isset($request->job_level_id)) {
            $newJob->jobLevels()->sync($request->job_level_id);
        } else {
            $newJob->jobCates()->sync(array());
        }
        return redirect()->route('job.index');
    }
public function store ( Request $ request ) { $ this -> validate ( $ request , [ 'name' => 'required|max:200' , 'job_type_id' => 'required|numeric' , 'job_cate_id' => 'array' , 'job_level_id' => 'array' , 'image' => 'required|max:200' , 'time_start' => 'required|date' , 'time_to' => 'required|date' , 'slug' => 'required|max:200' , 'company_id' => 'required|numeric' , 'country_id' => 'required|numeric' , 'description' => 'required' , 'salary' => 'required|max:200' , 'contentInfo' => 'required' ] ) ; $ newJob = new Job ( ) ; $ newJob -> setData ( $ request ) ; $ newJob -> save ( ) ; if ( isset ( $ request -> job_cate_id ) ) { $ newJob -> jobCates ( ) -> sync ( $ request -> job_cate_id ) ; } else { $ newJob -> jobCates ( ) -> sync ( array ( ) ) ; } if ( isset ( $ request -> job_level_id ) ) { $ newJob -> jobLevels ( ) -> sync ( $ request -> job_level_id ) ; } else { $ newJob -> jobCates ( ) -> sync ( array ( ) ) ; } return redirect ( ) -> route ( 'job.index' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
//            'province_id' => 'numeric', //            'district_id' => 'numeric',