/** * Remove the specified JobItems from storage. * * @param int $id * @return \Response */ public function destroy($id) { JobItems::destroy($id); return \Redirect::route('jobitems.index'); }
public function addItem(Request $request) { $data = $request->all(); $job = Jobs::find($data['job_id']); if (isset($data['id']) && !empty($data['id'])) { $item = $data['type'] == 'Service' ? Services::find($data['id']) : Parts::find($data['id']); } else { $item = $data['type'] == 'Service' ? new Services() : new Parts(); $item->description = $data['description']; $item->cost = $data['cost']; $item->save(); } $jobItem = new JobItems(); $jobItem->description = $data['description']; $jobItem->rate = $data['cost']; $jobItem->quantity = 1; $jobItem->vat = config('nodendb.vat'); $jobItem->job_id = $job->id; $jobItem->guitar_id = $data['guitar_id']; if ($data['type'] == 'Service') { $jobItem->service_id = $item->id; } else { $jobItem->part_id = $item->id; } $jobItem->save(); return $jobItem; }