app/Http/Controllers/JobManagerController.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, $id)
    {
        $job = Job::find($id);
        if($job) {
            $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'
            ]);
            $job->setData($request);
            $job->save();
            if(isset($request->job_cate_id)) {
                $job->jobCates()->sync($request->job_cate_id);
            } else {
                $job->jobCates()->sync(array());
            }
            if(isset($request->job_level_id)) {
                $job->jobLevels()->sync($request->job_level_id);
            } else {
                $job->jobCates()->sync(array());
            }
        }
        return redirect()->route('job.index');
    }
public function update ( Request $ request , $ id ) { $ job = Job :: find ( $ id ) ; if ( $ job ) { $ 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' ] ) ; $ job -> setData ( $ request ) ; $ job -> save ( ) ; if ( isset ( $ request -> job_cate_id ) ) { $ job -> jobCates ( ) -> sync ( $ request -> job_cate_id ) ; } else { $ job -> jobCates ( ) -> sync ( array ( ) ) ; } if ( isset ( $ request -> job_level_id ) ) { $ job -> jobLevels ( ) -> sync ( $ request -> job_level_id ) ; } else { $ job -> jobCates ( ) -> sync ( array ( ) ) ; } } return redirect ( ) -> route ( 'job.index' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .
//                'province_id' => 'numeric', //                'district_id' => 'numeric',