public function destroy($id)
 {
     $agency = Agency::where('id', $id)->get();
     $auditions = Agency::findOrFail($id)->auditions()->get();
     Agency::where('id', $id)->delete();
     //reindex za elasticsearch
     $agency->deleteFromIndex();
     foreach ($auditions as $audition) {
         $audition->removeFromIndex();
     }
     flash()->success('Agency has been successfully deleted');
     return redirect('/admin');
 }
Beispiel #2
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $agency = Agency::findOrFail($id);
     $agency->delete();
     flash()->success('Record deleted.');
     return redirect('admin/agencies');
 }
 /**
  * [update_pic description]
  * @param  Request $request [description]
  * @return [type]           [description]
  */
 public function update_pic($id, Request $request)
 {
     $agency = Agency::findOrFail($id);
     $img_path = 'images/agency_pic/';
     $pic = $request->file('agency_pic');
     //$img = Image::canvas(300, 300, '#ccc')->save($img_path . 'default.jpg');
     $img = Image::make($pic)->resize(300, 300)->save($img_path . $agency->id . '.jpg');
     $agency = $agency->update(['agency_pic' => $img_path . $agency->id . '.jpg']);
     $userId = Auth::user()->id;
     return redirect('/agencies/user/' . $userId);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param \Illuminate\Http\Request $request
  * @param int                      $id
  *
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     // Get the existing entry
     $agency = Agency::findOrFail($id);
     // Update entry
     $agency->update($request->all());
     /*
      * Redirect to works route with session
      * of the updated entry
      */
     return redirect()->route('dash.agencies')->with(['flash_entry_updated' => true, 'flash_entry_id' => $agency->id, 'flash_entry_title' => $agency->name, 'flash_entry_route' => 'dash.agencies.edit']);
 }