/** * Store a newly created visit in storage. * * @return Response */ public function store() { $phone_number = Input::only('phone_number'); $party = Party::where('phone_number', $phone_number)->first(); $data = Input::only('size'); $data['party_id'] = $party->id; $visit = Visit::create($data); return Response::json($visit); }
/** * Update the specified resource in storage. * PUT /api/partys * * @return Response */ public function update() { $data = Input::only('name', 'phone_number'); $party = Party::where('phone_number', $data['phone_number'])->first(); if ($party) { $party->name = $data['name']; $party->phone_number = $data['phone_number']; $party->save(); } else { $party = Party::create($data); } return Response::json($party); }