コード例 #1
0
ファイル: Cluster.php プロジェクト: kevineger/rally
 /**
  * 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;
 }
コード例 #2
0
 /**
  * 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'));
 }
コード例 #3
0
 /**
  * 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]);
 }
コード例 #4
0
 /**
  * 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();
     });
 }
コード例 #5
0
 public function destroy(Cluster $cluster)
 {
     Cluster::destroy($cluster->id);
     Flash::success('Cluster Deleted!');
     return redirect()->action('ClusterController@index');
 }
コード例 #6
0
 /**
  * @return \Illuminate\View\View
  */
 public function index()
 {
     $clusters = Cluster::lists('name', 'id');
     return view('registration.index', compact('clusters'));
 }