/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(FlowTemplateRequest $request) { if (Gate::denies('store-template')) { abort(403); } $flowTemplate = new FlowTemplate(); $flowTemplate->setAll($request); $flowTemplate->syncLocations($request->input('location')); return $flowTemplate; }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($issue) { if (Gate::denies('edit-issue')) { abort(403); } $flowTemplates = FlowTemplate::all(); $locationSteps = $issue->locationsteps()->orderBy('step_order', 'asc')->get(); return view('admin.backend.issues.edit', ['issue' => $issue, 'locationSteps' => $locationSteps, 'flowTemplates' => $flowTemplates]); }
/** @test */ public function create_a_complex_flowtemplate_with_locationsteps_and_flowsteps_and_edit() { $params = ['_token' => csrf_token(), 'name' => $this->faker->name]; $this->call('POST', action('FlowTemplateController@store'), $params); $deleteLineFromDb = FlowTemplate::where('name', $params['name'])->first(); $this->call('POST', 'backend/flowtemplate/' . $deleteLineFromDb->id, ['_method' => 'PUT', '_token' => csrf_token(), 'name' => 'Mihai']); $newName = FlowTemplate::find($deleteLineFromDb->id); $this->assertResponseOk(); $this->assertNotEquals($params['name'], $newName->name); $deleteLineFromDb->delete(); }