/** * Remove the specified resource from storage. * DELETE /admin\document/{id} * * @param int $id * @return Response */ public function destroy($id) { try { $doc = Document::find($id); if (File::exists(public_path() . $doc->path)) { File::delete(public_path() . $doc->path); } if ($doc->delete()) { return Response::json(['message' => 'A(z) ' . $id . ' azonosítójú dokumentum törlése sikerült!', 'status' => true]); } else { return Response::json(['message' => 'A(z) ' . $id . ' azonosítójú dokumentum törlése nem sikerült!', 'status' => false]); } } catch (Exception $e) { if (Config::get('app.debug')) { return Response::json(['message' => $e->getMessage(), 'status' => false]); } else { return Response::json(['message' => 'A(z) ' . $id . ' azonosítójú dokumentum törlése nem sikerült!', 'status' => false]); } } }
/** * Display a listing of the resource. * GET /site\document * * @return Response */ public function index() { View::share('title', 'Dokumentumok'); $this->layout->content = View::make('site.document.index')->with('documents', Document::all()); }