Exemplo n.º 1
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     try {
         $agent = Agent::with('agent_category')->findOrFail($id);
     } catch (ModelNotFoundException $e) {
         $errMsg = "Cannot find agent! Error on `edit` with ID={$id}";
         return redirect('masterdata/agent')->with('errMsg', $errMsg);
     }
     return view('masterdata/agent-form', ['agent' => $agent, 'agent_cat' => AgentCategory::all(), 'method' => 'PUT', 'form_action' => action('AgentController@update', $agent->id), 'agent_id' => $id]);
 }
Exemplo n.º 2
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     try {
         $agentCat = AgentCategory::findOrFail($id);
         $agentCat->delete();
         // Update all Agent tables too
         $execMsg = "Delete Successful!";
     } catch (ModelNotFoundException $e) {
         $execMsg = "Cannot delete record. Data not found.";
         return redirect('masterdata/agent-cat')->with('errMsg', $execMsg);
     }
     return redirect('masterdata/agent-cat')->with('message', $execMsg);
 }