public function store($projectId, Request $request)
 {
     $this->validate($request, ['work_id' => 'required', 'name' => 'required']);
     $work = \App\Entities\Work::findOrFail($request->input('work_id'));
     $project = \App\Entities\Project::findOrFail($projectId);
     $projectWork = $project->works()->create(array_merge($work->toArray(), ['name' => $request->input('name')]));
     $work->items->each(function ($item) use($projectWork) {
         $projectWork->workitems()->create($item->toArray());
     });
     if ($request->ajax()) {
         return response()->json();
     }
     return redirect()->route('projects.bid.works', $projectId);
 }
 public function store(Request $request)
 {
     $this->validate($request, ['name' => 'required']);
     $workflow = Workflow::create(['name' => $request->name]);
     if ($request->has('work_ids')) {
         $workIds = explode(',', $request->input('work_ids'));
         $works = Work::findOrFail($workIds);
         foreach ($works as $work) {
             $work->update(['workflow_id' => $workflow->id]);
         }
     }
     if ($request->ajax()) {
         return response()->json(compact('workflow'));
     }
     return redirect()->route('workflows.show', $workflow->id);
 }
Exemplo n.º 3
0
 public function workflow($workId)
 {
     $work = Work::findOrFail($workId);
     return view('works.workflow')->withWork($work);
 }