/** * Build a new cluster photo instance. * * @param $subreddit * @return mixed */ public static function named($subreddit) { $cluster = new Cluster(); $cluster->name = $subreddit; $cluster->saveAs($subreddit); $cluster->save(); return $cluster; }
/** * Delete Confirm * * @param int $id * @return View */ public function getModalDelete($id) { $error = null; $modal_title = trans('cluster/dialog.delete-confirm.title'); $modal_cancel = trans('general.button.cancel'); $modal_ok = trans('general.button.ok'); $cluster = $this->cluster->find($id); $modal_route = route('cluster.delete', ['id' => $cluster->id]); $modal_body = trans('cluster/dialog.delete-confirm.body', ['id' => $cluster->id, 'name' => $cluster->name]); return view('modal_confirmation', compact('error', 'modal_route', 'modal_title', 'modal_body', 'modal_cancel', 'modal_ok')); }
/** * Respond to AJAX requests to cluster a subreddit and return the path to image of clustering. * * @param Request $request * @return \Illuminate\Http\JsonResponse */ public function clusterSubreddit(Request $request) { $subreddit = $request->get('subreddit'); // Look for cached cluster $cluster_image = Cluster::where('name', $subreddit)->first(); // Else, perform new clustering if ($cluster_image == null) { // Perform the clustering and return the path to image. $path = $this->cluster->getSubredditSubmissionHistory($subreddit); // Save a copy of image to public folder $cluster_image = Cluster::named($subreddit); $cluster_image->move($path); } return response()->json(['path_to_image' => $cluster_image->path]); }
/** * Define your route model bindings, pattern filters, etc. * * @param \Illuminate\Routing\Router $router * @return void */ public function boot(Router $router) { // parent::boot($router); $router->bind('phone', function ($mac) { return \App\Phone::where('mac', $mac)->first(); }); $router->bind('bulk', function ($process_id) { return \App\Bulk::where('process_id', $process_id)->first(); }); $router->bind('cluster', function ($id) { return \App\Cluster::where('id', $id)->first(); }); $router->bind('user', function ($name) { return \App\User::where('name', $name)->first(); }); $router->bind('sql', function ($id) { return \App\Sql::where('id', $id)->first(); }); }
public function destroy(Cluster $cluster) { Cluster::destroy($cluster->id); Flash::success('Cluster Deleted!'); return redirect()->action('ClusterController@index'); }
/** * @return \Illuminate\View\View */ public function index() { $clusters = Cluster::lists('name', 'id'); return view('registration.index', compact('clusters')); }