/** * Show the form for creating a new resource. * * @return Response */ public function create(Request $request) { $part = SparePart::findOrFail($request->part_id); $type = $request->type; $submit = $request->submit; return view('spareparts.trans_create', compact('part', 'type', 'submit')); }
/** * Update the specified resource in storage. * * @param Request $request * @param int $id * @return Response */ public function update(Request $request, $id) { $repair = Repair::findOrFail($id); $repairin = $request->all(); $tech_arr = $request->input('technicans'); $repairin['tech_no'] = count($tech_arr); $repair->update($repairin); //loop throught technincans fields $part_arr = $request->input('part_id'); $qty_arr = $request->input('part_qty'); $repair->spare_parts()->detach(); foreach ($part_arr as $key => $part) { if ($part != 0) { $part_obj = SparePart::find($part); $rep_id = $repair->rep_id; $qty = $qty_arr[$key]; $part_obj->repair()->attach($rep_id, ['part_qty' => $qty]); } } $repair->technicans()->detach(); foreach ($tech_arr as $tech) { $tech_obj = Technican::find($tech); $tech_obj->repair()->attach($repair); } return redirect('maintainance/repairs'); }
/** * Update the specified resource in storage. * * @param Request $request * @param int $id * @return Response */ public function update(AddPartRequest $request, $id) { $part = SparePart::findOrFail($id); $part->update($request->all()); return redirect('spareparts'); }
/** * Update the specified resource in storage. * * @param Request $request * @param int $id * @return Response */ public function update(Request $request, $id) { $task = Task::findOrFail($id); $taskin = $request->all(); $task->update($taskin); //loop throught technincans fields $part_arr = $request->input('part_id'); $qty_arr = $request->input('part_qty'); $task->parts()->detach(); foreach ($part_arr as $key => $part) { if ($part != 0) { $part_obj = SparePart::find($part); $task_id = $task->task_id; $qty = $qty_arr[$key]; $part_obj->task()->attach($task_id, ['part_qty' => $qty]); } } return redirect('maintainance/tasks'); }
public function finish(Request $request, $id) { $task = Task::findOrFail($id); $task->update(['task_status' => 'تمت']); $task_id = $task->task_id; $tech = $request->tech_id; $technican = Technican::findOrFail($tech); $technican->task()->attach($task_id); //attaching spare_parts $part_arr = $request->input('part_id'); $qty_arr = $request->input('part_qty'); foreach ($part_arr as $key => $part) { if ($part != 0) { $part_obj = SparePart::find($part); $qty = $qty_arr[$key]; $part_obj->task()->attach($task_id, ['part_qty' => $qty]); } } return redirect('maintainance/tasks'); }