public function deploy()
 {
     /**
      * POST /apps/deploy -d
      * {
      *   branch : master,
      *   ref : tag/commit-hash,
      *   name : foobar
      * }
      * Creates :
      * $appPath/deploy/foobar/ <- full repo
      */
     $id = $this->request->id;
     $app = App::first($id);
     if ($this->request->data) {
         $deploy = $app->deploy($this->request->data);
         $repo = $app->repo();
         $deploy->checkout(compact('repo'));
         $this->redirect('Apps::view', array('args' => compact('id')));
     }
     $refs = array();
     foreach ($app->repo()->refs(100) as $r) {
         extract($r);
         $refs[$hash] = "{$date} : {$message}";
     }
     $branches = $app->repo()->branches();
     //$versions = $app->versions();
     $deployed = $app->deployed();
     if (!count($deployed)) {
         $defaults = array('target' => "/home/apps/" . strtolower($app->title), 'name' => 'default');
     }
     return compact('app', 'refs', 'defaults');
 }
 public function run()
 {
     $cate = ['Productivity', 'Finance', 'Travel', 'Business', 'Utilities'];
     $faker = Faker::create();
     foreach (range(200, 220) as $index) {
         App::create(['id' => $index, 'name' => $faker->word, 'rating' => $faker->numberBetween($min = 2, $max = 5), 'rating_users' => $faker->numberBetween($min = 5, $max = 20000), 'genre' => $cate[rand(0, 4)], 'arm' => 'armv7', 'description' => $faker->sentence, 'img_url' => $faker->imageUrl($width = 60, $height = 60)]);
     }
 }
Exemple #3
0
 /**
  * Route notifications for the Slack channel.
  *
  * @return string
  */
 public function routeNotificationForSlack()
 {
     if (\App::environment('production')) {
         return "https://hooks.slack.com/services/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";
     } else {
         return "https://hooks.slack.com/services/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";
     }
 }
 public function run()
 {
     $comment_list = ['看見麥兜總召的格局', '所以我說那個醬汁呢', '李嚴,你怎麼帥成這樣', '那些年,子洋的粉色泡泡', '刁難哥奇遇記', '轉角遇到典型的政大資管人', '喔~問題來了', '你這樣不Work', '資管迎新茶會 5/22 商院101 熱血開踢', '5/13 科技組晚上上課有演講者,歡迎到場', 'Hakuna Matata', '老王的五十個案子', '杰哥的衣服Queue', '中央資管,我愛你們全部', '阿~我們就全班宅男啊', '我都參考貝克漢穿搭耶', '這個大叔是哪來的', '現在放棄的話,就可以放暑假了', '潮水退了就知道誰沒穿褲子', '聽完周老師這番話,全資管系都驚呆了', '左手寫詩,右手寫程式', '啊不就好棒棒', '吃吃看,你吃一口就知道了', '德國拳王倒下去,莎拉布萊曼照唱  Time to say goodbye', '面對現實,不然現實就面對你', '棉被再怎麼抖都會有灰塵', '務必冷靜理性透徹,暫時把好惡丟到河流另一邊去', '怕熱就不要進廚房', '拿破崙說 由馴鹿所領導的獅子軍團 就在也不是獅子軍團', '甜甜圈~', '在非洲,每六十秒,就有一分鐘過去', '當你的左臉被人打,那你的左臉就會痛', '英國研究 生日過越多的人就越老', '當蝴蝶在南半球拍了兩下翅膀,牠就會稍微飛高一點點', '我買了130元的高級鵝肉飯'];
     //echo count($comment_list);
     $user_list = User::select('id')->lists('id');
     //echo var_dump($user_list);
     foreach ($user_list as $user_key => $user_value) {
         $app_ran_list = App::orderByRaw("RAND()")->take(35)->lists('id');
         foreach ($app_ran_list as $app_key => $app_value) {
             User_App_Comment::create(['u_id' => $user_value, 'a_id' => $app_value, 'comment' => $comment_list[$app_key]]);
         }
     }
 }
 public function getLocalizedColumn($key)
 {
     $locale = \App::getLocale();
     if (empty($locale)) {
         $locale = 'en';
     }
     $localizedKey = $key . '_' . strtolower($locale);
     $value = $this->{$localizedKey};
     if (empty($value)) {
         $localizedKey = $key . '_en';
         $value = $this->{$localizedKey};
     }
     return $value;
 }
Exemple #6
0
 private function notHas($uid, $app)
 {
     $app = App::find()->where(['code' => $app])->asArray()->one();
     $role = RoleUser::find()->where(['uid' => $uid])->asArray()->all();
     $roleid = array();
     foreach ($role as $vr) {
         $roleid[] = $vr['rid'];
     }
     $roleid = implode(',', $roleid);
     $rule = Rule::find()->select(['aid', 'role_id', 'model_id', 'feature_id', 'scope_id'])->where("role_id not in({$roleid})")->andWhere(['aid' => $app['id']])->asArray()->all();
     $result = array();
     $unique = array();
     foreach ($rule as $k => $vu) {
         $apps = App::find()->select(['name'])->where(['id' => $vu['aid']])->asArray()->one();
         $result[$k]['app'] = $apps['name'];
         $roles = Role::find()->select(['name'])->where(['id' => $vu['role_id']])->asArray()->one();
         $result[$k]['role'] = $roles['name'];
         $model = Model::find()->select(['name'])->where(['id' => $vu['model_id']])->asArray()->one();
         $result[$k]['model'] = $model['name'];
         $feature = Feature::find()->select(['name'])->where(['id' => $vu['feature_id']])->asArray()->one();
         $result[$k]['feature'] = $feature['name'];
         $scopes = Rule::find()->select(['scope_id'])->where(['aid' => $vu['aid'], 'role_id' => $vu['role_id'], 'model_id' => $vu['model_id'], 'feature_id' => $vu['feature_id']])->asArray()->all();
         foreach ($scopes as $ks => $vs) {
             $scope = Scope::find()->select(['name', 'attribute'])->where(['id' => $vs['scope_id']])->asArray()->one();
             $result[$k]['scope'][$ks]['name'] = $scope['name'];
             $result[$k]['scope'][$ks]['attribute'] = $scope['attribute'];
         }
         $unique[$k] = $vu['aid'] . $vu['role_id'] . $model['name'] . $feature['name'];
     }
     // delete the repeat elements
     $unique = array_unique($unique);
     $res = array();
     foreach ($unique as $kq => $vq) {
         $res[] = $result[$kq];
     }
     return $res;
 }
Exemple #7
0
 public function getPresenter()
 {
     return \App::make(DragonPresenter::class, [$this]);
 }
Exemple #8
0
 public function lar_ver()
 {
     $app = \App::getFacadeApplication();
     return $app::VERSION;
 }
 /**
  * appList.
  *
  * @param Request $request request object
  *
  * @return Array
  */
 public function appList(Request $request)
 {
     $apps = App::distinct()->orderBy('created_at', 'desc');
     $apps = $apps->get();
     return view('applist', ['apps' => $apps]);
 }
Exemple #10
0
 /**
  * Search by elasticsearch
  * @return Model
  */
 public function elasticSearch(array $options)
 {
     $es = \App::make('elasticsearch');
     $params = ["index" => $this->getElasticIndex(), "type" => $this->getElasticType(), "body" => ["query" => ["bool" => ["must" => []]]]];
     $results = [];
     foreach ($options as $key => $value) {
         $params["body"]["query"]["bool"]["must"][] = ["match" => [$key => $value]];
     }
     try {
         $search = $es->search($params);
     } catch (Exception $e) {
         return mull;
     }
     foreach ($search["hits"]["hits"] as $key => $value) {
         $results[] = $this->find($value["_source"]["id"]);
     }
     return collect($results);
 }
Exemple #11
0
 public static function getMetaCount($id, $action)
 {
     $es = self::connect();
     if ($id === null) {
         App::abort(404, 'No note id passed');
     }
     $annotation = static::find($id);
     $action_count = $annotation->{$action}();
     return $action_count;
 }
 private function unfoldMessageInfo($message)
 {
     $onlyNeedFeilds = ['id', 'name', 'avatar_url'];
     $app = App::where('client_id', $message->app_id)->first();
     if ($app) {
         $message->app = array_only($app->toArray(), ['client_id', 'name', 'logo_url', 'homepage_url']);
     }
     $author = User::find($message->author_id);
     if ($author) {
         $message->author = array_only($author->toArray(), $onlyNeedFeilds);
     }
     $receiver = User::find($message->receiver_id);
     if ($receiver) {
         $message->receiver = array_only($receiver->toArray(), $onlyNeedFeilds);
     }
     $allReceiverIds = [];
     if (!empty($message->all_receiver_ids)) {
         $allReceiverIds = explode(',', $message->all_receiver_ids);
     }
     $all_receivers = [];
     foreach ($allReceiverIds as $receiverId) {
         $user = User::find($receiverId);
         if ($user) {
             array_push($all_receivers, array_only($user->toArray(), $onlyNeedFeilds));
         }
     }
     $message->all_receivers = $all_receivers;
     return $message;
 }
 public function destroy($id)
 {
     $app = App::where('client_id', $id)->first();
     if (!$app) {
         return response()->json(['error' => '资源不存在'], 404);
     }
     $client = OAuthClient::find($app->client_id);
     if ($client) {
         $client->delete();
     }
     $endpoint = OAuthClientEndPoint::find($app->client_id);
     if ($endpoint) {
         $endpoint->delete();
     }
     OAuthClientScope::where('client_id', $app->client_id)->delete();
     $app->delete();
     return response('', 204);
 }
 public function getPresenter()
 {
     return \App::make(CollectTimesPresenter::class, [$this]);
 }
Exemple #15
0
 public function getApp()
 {
     return $this->hasOne(App::className(), ['id' => 'aid'])->asArray();
 }
 public function run()
 {
     App::create(['id' => '123', 'cl_id' => '2', 'name' => 'SosLab App', 'genre' => 'Music', 'rating' => '4.5', 'rating_users' => '45', 'r1_score' => '2', 'r2_score' => '3', 'r3_score' => '5', 'total_score' => '10', 'arm' => 'armv7', 'description' => 'Soslab', 'img_url' => 'http://is1.mzstatic.com/image/pf/us/r30/Purple5/v4/12/3d/be/123dbee0-d119-f4e5-a843-9392dcecf51f/AppIcon60x60_U00402x.png']);
     App::create(['id' => '456', 'cl_id' => '2', 'name' => 'ICTLab App', 'genre' => 'Games', 'rating' => '2', 'rating_users' => '23', 'r1_score' => '4', 'r2_score' => '3', 'r3_score' => '5', 'total_score' => '12', 'arm' => 'armv7', 'description' => 'ICTlab', 'img_url' => 'http://is3.mzstatic.com/image/pf/us/r30/Purple7/v4/19/dd/7b/19dd7bc0-ae03-d82d-f183-d66e74fb5f1c/Icon-Production.png']);
     App::create(['id' => '789', 'cl_id' => '3', 'name' => 'KMLab App', 'genre' => 'Sports', 'rating' => '4', 'rating_users' => '12', 'r1_score' => '4', 'r2_score' => '3', 'r3_score' => '6', 'total_score' => '13', 'arm' => 'armv7', 'description' => 'KMlab', 'img_url' => 'http://is4.mzstatic.com/image/pf/us/r30/Purple7/v4/16/35/5e/16355e45-6fbd-f871-5903-d6a53a53eeb2/ProductionAppIcon57x57.png']);
 }
Exemple #17
0
 private function notHas($uid, $app, $feature)
 {
     $app = App::find()->select(['id', 'name'])->where(['code' => $app])->asArray()->one();
     $role = RoleUser::find()->select(['rid', 'rname'])->where(['uid' => $uid])->asArray()->all();
     $roleid = array();
     foreach ($role as $vr) {
         $roleid[] = $vr['rid'];
     }
     $roleid = implode(',', $roleid);
     $scopes = Rule::find()->select(['model_id', 'scope_id'])->where(['aid' => $app['id']])->andWhere(['feature_code' => $feature])->andWhere("role_id not in({$roleid})")->asArray()->all();
     $feature = Feature::find()->select(['name'])->where(['code' => $feature])->asArray()->one();
     // delete repeat data
     $unique = array();
     foreach ($scopes as $k => $vs) {
         $unique[$k] = $vs['model_id'] . ',' . $vs['scope_id'];
     }
     $scope = array_unique($unique);
     $result = array();
     foreach ($scope as $k => $v) {
         $result[] = $scopes[$k];
     }
     $final = array();
     foreach ($result as $k => $vu) {
         $model = Model::find()->select(['name'])->where(['id' => $vu['model_id']])->asArray()->one();
         $scope = Scope::find()->select(['name', 'attribute'])->where(['id' => $vu['scope_id']])->asArray()->one();
         $final[$k]['model'] = $model['name'];
         $final[$k]['feature'] = $feature['name'];
         $final[$k]['scope'] = $scope['name'];
         $final[$k]['scope_attribute'] = $scope['attribute'];
     }
     return $final;
 }
 private function unfoldFavorInfo($favor)
 {
     $author = User::find($favor->author_id);
     if ($author) {
         $favor->author = array_only($author->toArray(), ['id', 'name', 'avatar_url']);
     }
     $app = App::where('client_id', $favor->app_id)->first();
     if ($app) {
         $favor->app = array_only($app->toArray(), ['client_id', 'name', 'logo_url', 'homepage_url']);
     }
     return $favor;
 }
 public function getAuthClient()
 {
     $clientId = Authorizer::getClientId();
     $app = App::where('client_id', $clientId)->first();
     return response()->json($app);
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     //
     $status = Input::get('status');
     if ($status == 'comment') {
         $comment_new = User_App_Comment::join('apps', 'apps.id', '=', 'user__app__comments.a_id')->join('users', 'users.id', '=', 'user__app__comments.u_id')->select('user__app__comments.id', 'users.name as user_name', 'users.id as user_id', 'users.img as user_img', 'apps.id as app_id', 'apps.name as app_name', 'apps.img_url as app_img', 'comment', 'user__app__comments.created_at')->orderBy('user__app__comments.created_at', 'desc')->where('user__app__comments.a_id', '=', $id);
         $return_all = $comment_new->get();
         $empty_test = $comment_new->first();
         if (empty($empty_test)) {
             return Response::json(array('message' => 'No comments', 'status' => 'error'));
         }
         return $return_all;
     }
     $app_detail = App::where('id', '=', $id)->first();
     $app_behaviors = App::join('app__behaviors', 'app__behaviors.a_id', '=', 'apps.id')->join('behaviors', 'behaviors.id', '=', 'app__behaviors.b_id')->where('apps.id', '=', $id)->select('behaviors.id', 'behaviors.name', 'behaviors.genre', 'app__behaviors.score')->orderBy('behaviors.genre', 'asc')->orderBy('behaviors.id', 'asc')->get();
     $app_comments = User_App_Comment::join('apps', 'apps.id', '=', 'user__app__comments.a_id')->join('users', 'users.id', '=', 'user__app__comments.u_id')->where('user__app__comments.a_id', '=', $id)->select('user__app__comments.id', 'users.id as user_id', 'users.name as user_name', 'apps.id as app_id', 'apps.name as app_name', 'apps.img_url as app_img', 'comment', 'user__app__comments.created_at as comment_time')->orderBy('user__app__comments.created_at', 'desc')->get();
     $app_favorite_counts = App::join('user__app__favorite', 'user__app__favorite.a_id', '=', 'apps.id')->where('apps.id', '=', $id)->count();
     $app_comment_counts = App::join('user__app__comments', 'user__app__comments.a_id', '=', 'apps.id')->where('apps.id', '=', $id)->count();
     $app_clusters = Cluster::join('apps', 'apps.cl_id', '=', 'clusters.id')->where('apps.id', '!=', $id)->where('clusters.id', '=', $app_detail['cl_id'])->get();
     $app_detail->behaviors = $app_behaviors;
     $app_detail->comments = $app_comments;
     $app_detail->favorite_count = $app_favorite_counts;
     $app_detail->comment_count = $app_comment_counts;
     $app_detail->group_app = $app_clusters;
     if (Auth::check()) {
         $user_id = Auth::user()->id;
         $check_suck = User::join('user__app__favorite', 'user__app__favorite.u_id', '=', 'users.id')->where('user__app__favorite.a_id', '=', $id)->where('user__app__favorite.u_id', '=', $user_id)->first();
         if (empty($check_suck)) {
             $user_favorite = "Not yet";
         } else {
             $user_favorite = "Already";
         }
     } else {
         $user_favorite = "Not login";
     }
     $app_detail->user_favorite = $user_favorite;
     $app_detail->success = 'success';
     return $app_detail;
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table("apps")->delete();
     App::create(['client_id' => 'koala', 'name' => 'Koala', 'author_id' => 1, 'homepage_url' => 'http://121.42.144.117:2111', 'logo_url' => 'https://www.prepbootstrap.com/bootstrap-theme/shield/preview/images/team/team04.jpg', 'description' => '西邮Linux兴趣小组资源管理平台', 'secret' => '$2y$10$8Gz5X7XkQtVzwFU8C9zSQ.FzIH6OZNd5D', 'redirect_uri' => 'http://121.42.144.117:2111/connect/adam/callback', 'status' => 3, 'submit_status' => 3, 'scopes' => 'all']);
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getApp()
 {
     return $this->hasOne(App::className(), ['id' => 'appid']);
 }
 public function __construct(array $attributes = array(), Validator $validator = null)
 {
     parent::__construct($attributes);
     $this->validator = $validator ?: \App::make('validator');
 }