/** * Display a listing of the resource. * * @return Response */ public function index() { $archives = Archive::select('year')->distinct()->get(); foreach ($archives as $archive) { $archive['months'] = Archive::select('id', 'month')->where('year', $archive->year)->get()->toJson(); } return $archives->toJson(); }
/** * Show the form for creating a new resource. * * @return Response */ public function create() { // queries the clients db table, orders by client_name and lists client_name and id //$applications = DB::table('applications')->orderBy('id', 'asc')->lists('name','id'); $applications = Application::lists('name', 'id'); $archives = Archive::lists('name', 'id'); return view('versions.create', array('applications' => $applications, 'archives' => $archives)); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy(Post $post) { $posts = Post::where('archive_id', $post->archive_id)->get(); if (sizeof($posts) <= 1) { $post->delete(); Archive::find($post->archive_id)->delete(); } else { $post->delete(); } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { Archive::find($id)->delete(); return redirect('archives'); }