Ejemplo n.º 1
0
 /**
  * Get a user's repos.
  *
  * @param \StyleCI\StyleCI\Models\User $user
  * @param bool                         $admin
  *
  * @return array
  */
 public function get(User $user, $admin = false)
 {
     // cache the repo info from github for 12 hours
     $list = $this->cache->remember($user->id . 'repos', 720, function () use($user) {
         return $this->fetchFromGitHub($user);
     });
     foreach (Repo::whereIn('id', array_keys($list))->get() as $repo) {
         $list[$repo->id]['enabled'] = true;
         $this->syncWithDatabase($repo, $list[$repo->id]);
     }
     return $list;
 }
Ejemplo n.º 2
0
 /**
  * Find all repos a user can view.
  *
  * @param \StyleCI\StyleCI\Models\User $user
  * @param bool                         $admin
  *
  * @return \Illuminate\Database\Eloquent\Collection
  */
 public function allByUser(User $user, $admin = false)
 {
     return Repo::whereIn('id', array_keys($this->repos->get($user, $admin)))->orderBy('name', 'asc')->get();
 }