public function index() { $usersData = []; $usersData['count'] = User::all()->count(); $usersData['incompleteCount'] = User::where('status', 0)->count(); $picsData = []; $picsData['count'] = Pic::all()->count(); $clubsData = []; $clubsData['count'] = Club::all()->count(); $badgesData = []; $badgesData['count'] = Badge::all()->count(); $fixtures = Fixture::all(); $fixturesData = []; $fixturesData['count'] = $fixtures->count(); $fixturesData['overCount'] = $fixtures->filter(function ($fxt) { return $fxt->isOver(); })->count(); $fixturesData['closedNotOverCount'] = $fixtures->filter(function ($fxt) { return $fxt->isClosed() and !$fxt->isOver(); })->count(); $gameweeks = Gameweek::all(); $gameweeksData = []; $gameweeksData['count'] = $gameweeks->count(); $gameweeksData['completeCount'] = Gameweek::complete()->get()->count(); $gameweeksData['pendingCount'] = Gameweek::incomplete()->get()->filter(function ($gw) { return $gw->hasCompletedFixture(); })->count(); $adminsData = []; $adminsData['count'] = Admin::all()->count(); return view('admin.dashboard.index', compact('usersData', 'picsData', 'clubsData', 'badgesData', 'fixturesData', 'gameweeksData', 'adminsData')); }
public function deletePic(Request $request) { $pic = Pic::find($request->id); // DELETE THE IMAGES ON SERVER ALSO!!! $rootPath = getcwd() . '/images/'; $rootURI = url('/') . '/images/'; $filename = substr($pic->url, strlen($rootURI)); $image_path = getcwd() . '/images/' . $filename; if (!unlink($image_path)) { echo "Error deleting {$file}"; } $pic->delete(); $pic = Pic::where('id', '>', $request->id)->orderBy('id', 'asc')->get()->first(); if ($pic) { return view('viewPic', ['url' => $pic->url, 'id' => $pic->id, 'created_at' => $pic->created_at]); } else { return view('viewPic', ['url' => url('/') . '/images/outofpics.png', 'id' => $request->id + 1, 'created_at' => "not found"]); } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $pic = Pic::findOrFail($id); $pic->delete(); return redirect('/admin/pic'); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $club = Club::findOrFail($id); $pics = Pic::lists('path', 'id')->toArray(); return view('admin.club.edit', compact('club', 'pics')); }