/** * 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(); }); }