/** * Process datatables ajax request. * * @return \Illuminate\Http\JsonResponse */ public function anyData() { return Datatables::of(Services::select('*'))->make(true); }
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; }