/**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $magz = Magazine::all();
     $distPlan = DistPlan::with('edition.magazine')->find($id);
     return view('circulation/distribution-plan-form', ['distPlan' => $distPlan, 'distID' => $id, 'magList' => $magz, 'method' => 'PUT', 'form_action' => action('DistributionPlanController@update', $id)]);
 }
Exemplo n.º 2
0
 /**
  * Return form view to create report
  *
  * @return Response
  */
 public function getCreateDistRealization()
 {
     $magazines = Magazine::all();
     $editions = Edition::with('magazine')->orderBy('magazine_id')->get();
     return view('report/form-dist-realization', ['magazines' => $magazines, 'editions' => $editions]);
 }
Exemplo n.º 3
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     try {
         $edition = Edition::with('magazine')->findOrFail($id);
     } catch (ModelNotFoundException $e) {
         $execMsg = "Cannot show magazine. Error on ID={$id}";
         return redirect('masterdata/edition/')->with('errMsg', $execMsg);
     }
     return view('masterdata/edition-form', ['edition' => $edition, 'magazines' => Magazine::all(), 'method' => 'PUT', 'edition_id' => $id, 'form_action' => action("EditionController@update", $id)]);
 }
Exemplo n.º 4
0
 /**
  * Process request to create new relationship
  *
  * @param Request request
  * @return Response
  */
 public function postCreateRelationship(Request $request)
 {
     $this->validate($request, ['magazine_id' => 'required|numeric', 'agent_id' => 'required|numeric']);
     $agent_id = $request->agent_id;
     $magazine_id = $request->magazine_id;
     // Get current agent
     try {
         $agent = Agent::findOrFail($agent_id);
         $magazine = Magazine::findOrFail($magazine_id);
     } catch (ModelNotFoundException $e) {
         $errMsg = "Cannot find agent/magazine! Error on `CreateRelationship` with agent ID={$agent_id} and magazine ID={$magazine_id}";
         return redirect('masterdata/agent')->with('errMsg', $errMsg);
     }
     $agent = $agent->magazine()->save($magazine);
     // Add new entry
     return redirect("masterdata/agent/relationship/{$agent_id}")->with('message', 'Added new relationship!');
 }
Exemplo n.º 5
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     try {
         $magz = Magazine::findOrFail($id);
         $magz->delete();
         //Set result message as flashdata
         $execMsg = "Deletion successful!";
     } catch (ModelNotFoundException $e) {
         //In case of failure on deletion/finding data, set errMsg
         $execMsg = "Cannot delete record. Data not found.";
         return redirect('masterdata/magazine')->with('errMsg', $execMsg);
     }
     return redirect('masterdata/magazine')->with('message', $execMsg);
 }