Пример #1
0
 public function show($groupName)
 {
     $group = Group::name($groupName)->with('creator')->firstOrFail();
     $group->checkAccess();
     $stats = ['contents' => intval(Content::where('group_id', $group->getKey())->count()), 'comments' => intval(Content::where('group_id', $group->getKey())->sum('comments')), 'entries' => intval(Entry::where('group_id', $group->getKey())->count()), 'banned' => intval(GroupBanned::where('group_id', $group->getKey())->count()), 'subscribers' => $group->subscribers, 'moderators' => intval(GroupModerator::where('group_id', $group->getKey())->count())];
     return array_merge($group->toArray(), ['stats' => $stats]);
 }
Пример #2
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $x = 1;
     foreach (Group::all() as $group) {
         $contents = Content::where('group_id', $group->getKey())->count();
         $entries = Entry::where('group_id', $group->getKey())->count();
         $total = $contents + $entries;
         // Default activity is medium = 2
         $group->activity = 2;
         // Low activity, when nothing was added last week
         if ($total == 0) {
             $group->activity = 1;
         }
         if ($total > 15) {
             $group->activity = 3;
         }
         if ($total > 50) {
             $group->activity = 4;
         }
         $group->save();
         if (!($x % 100)) {
             $this->info($x . ' groups processed');
         }
         $x++;
     }
     $this->info('All groups processed');
 }
 protected function isValidSlug()
 {
     $slugs = Entry::where('slug', '=', $this->data['slug'])->first();
     if ($slugs > 0) {
         return;
     } else {
         $this->data['slug'] = $this->data['slug'] . $slugs;
     }
 }
 /**
  * Updates the admin entry.
  */
 public function updateEntry()
 {
     $input = Input::all();
     $entry = Entry::where('email', 'admin')->first();
     if ($entry) {
         $entry->update($input);
         $entry->save();
     }
     return Redirect::route('admin.index')->withInfo('Admin entry saved.');
 }
Пример #5
0
 /**
  * Display the specified resource.
  *
  * @param  int  $logbook_id
  * @return Response
  */
 public function show($logbook_id)
 {
     try {
         $logbook = Logbook::findOrFail($logbook_id);
         $entries = Entry::where('logbook_id', $logbook_id)->orderBy('finished_at', 'desc')->orderBy('started_at', 'desc')->paginate(10);
         return View::make('logbooks.show', array('logbook' => $logbook, 'entries' => $entries));
     } catch (ModelNotFoundException $e) {
         return Redirect::to(route('logbooks.index'))->with('message', ['content' => 'Logboek niet gevonden!', 'class' => 'danger']);
     }
 }
 public function showAsAuthor($token)
 {
     $entry = Entry::where('token', '=', $token)->first();
     if ($entry) {
         $positiveVotes = $entry->upVotes();
         $negativeVotes = $entry->downVotes();
         return View::make('entries.show')->with('entry', $entry)->with('votes_count', $entry->votes()->count())->with('positiveVotes', $positiveVotes)->with('negativeVotes', $negativeVotes)->with('is_author', true);
     } else {
         App::abort(404);
     }
 }
Пример #7
0
 public static function create($entry_id, $entry_type, $privacy)
 {
     $entry = Entry::where('entry_id', $entry_id)->where('type', $entry_type)->get()->first();
     if ($entry->count() > 0) {
         $entry->entry_id = $entry_id;
         $entry->type = $entry_type;
         $entry->privacy = $privacy;
         return $entry->save();
     } else {
         return false;
     }
 }
Пример #8
0
 private function getViewProfileDatas($user_id)
 {
     $privacy = Privacy::where('name', "Công khai")->get()->first();
     $datas = array();
     if (FEUsersHelper::isCurrentUser($user_id)) {
         $entries = Entry::where('user_id', $user_id)->orderBy('updated_at', 'DESC')->paginate($this->entries_per_page);
         $left_albums = Album::where('user_id', $user_id)->orderBy('updated_at', 'DESC')->get();
     } else {
         $entries = Entry::where('user_id', $user_id)->where('privacy', $privacy->id)->orderBy('updated_at', 'DESC')->paginate($this->entries_per_page);
         $left_albums = Album::where('user_id', $user_id)->where('privacy', 1)->orderBy('updated_at', 'DESC')->get();
     }
     return array("entries" => $entries, "left_albums" => $left_albums);
 }
Пример #9
0
 /**
  * Calculates the score for this entry.
  */
 public function calculateScore()
 {
     // Start with the group matches
     $score = $this->calculateMatchPredictionsScore();
     $admin_entry = Entry::where('email', 'admin')->first();
     if ($admin_entry) {
         $score = $score + $this->calculateGroupPredictionsScore($admin_entry);
         $score = $score + $this->calculateFinalEightScore($admin_entry);
         $score = $score + $this->calculateFinalFourScore($admin_entry);
         $score = $score + $this->calculateFinalTwoScore($admin_entry);
         $score = $score + $this->calculateWinnerScore($admin_entry);
     }
     $this->score = $score;
     $this->save();
 }
 public function requeue_deadbeats()
 {
     dd("Don't run me yet, I'm not ready.");
     foreach (Entry::where('file_sha', null)->where('is_dir', 0)->get() as $entry) {
         $data = ['action' => 'create', 'entry' => $entry->toArray()];
         if (!$stored_entry->is_dir) {
             Queue::push('FileHandlerController@create', $data, $this->file_queue_id);
         }
     }
 }
Пример #11
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $entry = Entry::where('entid', '=', $id)->with('section')->get();
     //dd($entry[0]);
     // does user have access?
     if ($entry[0]->uid != $this->user->uid) {
         return Response::json(array('status' => false, 'errors' => array('total' => 'You are not authorized to delete this entry.')), 400);
     }
     //dd($entry[0]);
     if (Entry::delete_entry($id)) {
         if ($entry[0]->type == 100) {
             // SPECIAL CASE; deleting a monthly reset.
             $tmp = [];
             foreach ($entry[0]->section as $es) {
                 $tmp['balance'] = $es->amount;
                 DB::table('user_categories')->where('ucid', $es->ucid)->update($tmp);
             }
             return Response::json(array('success' => true), 200);
         }
         // first do reverse math on entry
         // fun stuff; if its a cc entry we're reversing, gotta be funky because I am a moron and did the
         // stupid ucid = 0 for everyones bank instead of just having an extra row for each user.
         $is_add = 0;
         if ($entry[0]->type == 50 || $entry[0]->type == 10 && $entry[0]->paid_to == 0) {
             $is_add = 1;
         }
         $this->do_the_math($id, $entry[0]->paid_to, $entry[0]->total_amount, $entry[0]->purchase_date, $is_add, 0, 1);
         // Then for each entry section
         foreach ($entry[0]->section as $es) {
             $this->do_the_math($id, $es->ucid, $es->amount, $entry[0]->purchase_date, 1, 0, 1, $es->paid_from, $entry[0]->type);
         }
         return Response::json(array('success' => true), 200);
     } else {
         return Response::json(array('status' => false, 'errors' => array('total' => 'There was a problem deleting this entry.')), 400);
     }
 }
Пример #12
0
 public function archive($date)
 {
     $entries = Entry::where('created_at', '>=', $date)->where('created_at', '<=', $date . ' 23:59:59')->where('user_id', '=', Auth::user()->id)->get();
     $totalCalories = 0;
     $totalFats = 0;
     $totalCarbs = 0;
     $totalProteins = 0;
     foreach ($entries as $entry) {
         $totalCalories += $entry->calories;
         $totalFats += $entry->fats;
         $totalCarbs += $entry->carbohydrates;
         $totalProteins += $entry->proteins;
     }
     return View::make('entries.index')->with(compact('entries'))->with(compact('totalCalories'))->with(compact('totalFats'))->with(compact('totalCarbs'))->with(compact('totalProteins'));
 }
 public function search($value)
 {
     return Response::json(Entry::where('name', 'LIKE', "%{$value}%")->get());
 }
 /**
  * Confirms an entry to make it visible on the scoreboard. 
  */
 public function confirm($confirmation)
 {
     $entry = Entry::where('confirmation', $confirmation)->first();
     if ($entry) {
         $entry->confirmation = null;
         $entry->save();
         return View::make('entry.confirm');
     }
     return Redirect::route('entry.index')->withMessage("Sorry, the entry could not be confirmed.");
 }
 public function results()
 {
     $matches = Match::all();
     $admin_entry = Entry::where('email', 'admin')->first();
     return View::make('results')->with('matches', $matches)->with('entry', $admin_entry);
 }
Пример #16
0
 public function getEntry()
 {
     return Entry::where('entry_id', $this->id)->where('type', 3)->get()->first();
 }
Пример #17
0
 /**
  * Display the specified resource.
  * GET /entries/{slug}
  *
  * @param  string  $slug
  * @return Response
  */
 public function show($slug)
 {
     $entry = Entry::where('slug', '=', $slug)->first();
     return View::make('entries.show', compact(['entry']));
 }