public function store(Request $request)
    {
        /** @noinspection PhpUndefinedMethodInspection */
        $request->validate([
            'memberIds.*' => 'required|exists:' . config('combine-core.tablePrefix', 'combine') . '_members,id',
            'memberTagIds.*' => 'required|exists:' . config('combine-core.tablePrefix', 'combine') . '_member_tags,id',
            'locationId' => 'exists:' . config('combine-core.tablePrefix', 'combine') . '_locations,id',
            'start' => 'required|date',
        ]);
        $job = new Job;
        $job->start = Carbon::parse($request->start);
        $job->location_id = $request->locationId;
        $job->team_id = $this->userContext()->team_id;
        $job->save();
        $job->members()->attach($request->memberIds);
        $job->member_tags()->attach($request->memberTagIds);
        return fractal($job, new JobTransformer())
            ->withResourceName('job')
            ->respond();
    }
public function store(Request $request)
    {
        /** @noinspection PhpUndefinedMethodInspection */
        $request->validate([
            'memberIds.*' => 'required|exists:' . config('combine-core.tablePrefix', 'combine') . '_members,id',
            'memberTagIds.*' => 'required|exists:' . config('combine-core.tablePrefix', 'combine') . '_member_tags,id',
            'locationId' => 'exists:' . config('combine-core.tablePrefix', 'combine') . '_locations,id',
            'start' => 'required|date',
        ]);
        $job = new Job;
        $job->start = Carbon::parse($request->start);
        $job->location_id = $request->locationId;
        $job->team_id = $this->userContext()->team_id;
        $job->save();
        $job->members()->attach($request->memberIds);
        $job->member_tags()->attach($request->memberTagIds);
        return fractal($job, new JobTransformer())
            ->withResourceName('job')
            ->respond();
    }
public function store ( Request $ request ) { /** @noinspection PhpUndefinedMethodInspection */ $ request -> validate ( [ 'memberIds.*' => 'required|exists:' . config ( 'combine-core.tablePrefix' , 'combine' ) . '_members,id' , 'memberTagIds.*' => 'required|exists:' . config ( 'combine-core.tablePrefix' , 'combine' ) . '_member_tags,id' , 'locationId' => 'exists:' . config ( 'combine-core.tablePrefix' , 'combine' ) . '_locations,id' , 'start' => 'required|date' , ] ) ; $ job = new Job ; $ job -> start = Carbon :: parse ( $ request -> start ) ; $ job -> location_id = $ request -> locationId ; $ job -> team_id = $ this -> userContext ( ) -> team_id ; $ job -> save ( ) ; $ job -> members ( ) -> attach ( $ request -> memberIds ) ; $ job -> member_tags ( ) -> attach ( $ request -> memberTagIds ) ; return fractal ( $ job , new JobTransformer ( ) ) -> withResourceName ( 'job' ) -> respond ( ) ; }
Store a newly created Job

@param  \Illuminate\Http\Request $request
@return \Illuminate\Http\Response JSON object with arrays of ids and links to newly created Jobs
Store a newly created Job