当前位置: 首页>>代码示例>>PHP>>正文


PHP presence函数代码示例

本文整理汇总了PHP中presence函数的典型用法代码示例。如果您正苦于以下问题:PHP presence函数的具体用法?PHP presence怎么用?PHP presence使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了presence函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getLogDataAttribute

 public function getLogDataAttribute($value)
 {
     if (presence($value) === null) {
         return [];
     }
     return unserialize($value);
 }
开发者ID:ameliaikeda,项目名称:osu-web,代码行数:7,代码来源:Log.php

示例2: deleteFile

 public function deleteFile()
 {
     if (presence($this->hash) === null) {
         return;
     }
     return $this->storage()->deleteDirectory($this->fileDir());
 }
开发者ID:nanaya,项目名称:osu-web,代码行数:7,代码来源:Imageable.php

示例3: transform

 public function transform(BeatmapDiscussionPost $post)
 {
     if (!priv_check('BeatmapDiscussionPostShow', $post)->can()) {
         return [];
     }
     return ['id' => $post->id, 'beatmap_discussion_id' => $post->beatmap_discussion_id, 'user_id' => $post->user_id, 'last_editor_id' => presence($post->last_editor_id, $post->user_id), 'deleted_by_id' => $post->deleted_by_id, 'system' => $post->system, 'message' => $post->message, 'created_at' => json_time($post->created_at), 'updated_at' => json_time($post->updated_at), 'deleted_at' => json_time($post->deleted_at)];
 }
开发者ID:ppy,项目名称:osu-web,代码行数:7,代码来源:BeatmapDiscussionPostTransformer.php

示例4: rawMessage

 public function rawMessage()
 {
     if ($this->can()) {
         return;
     }
     return presence($this->rawMessage, 'unauthorized');
 }
开发者ID:ppy,项目名称:osu-web,代码行数:7,代码来源:AuthorizationResult.php

示例5: store

 public function store(HttpRequest $request, $forum_id)
 {
     $this->validate($request, ['title' => 'required', 'body' => 'required']);
     $forum = Forum::findOrFail($forum_id);
     $this->authorizePost($forum, null);
     $topic = Topic::createNew(['forum' => $forum, 'title' => $request->input('title'), 'poster' => Auth::user(), 'body' => $request->input('body'), 'notifyReplies' => false, 'cover' => TopicCover::findForUse(presence($request->input('cover_id')), Auth::user())]);
     Event::fire(new TopicWasCreated($topic, $topic->posts->last(), Auth::user()));
     return ujs_redirect(route('forum.topics.show', $topic));
 }
开发者ID:Hughp135,项目名称:osu-web,代码行数:9,代码来源:TopicsController.php

示例6: handle

 /**
  * Add turbolinks-redirect header if previous request
  * was a redirect.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $isTurbolinks = presence($request->header('Turbolinks-Referrer'));
     $response = $next($request);
     // symphony responder (debug error page) doesn't have header method
     $isNormalResponse = method_exists($response, 'header');
     if ($isTurbolinks && $isNormalResponse) {
         return $response->header('Turbolinks-Location', $request->fullUrl());
     }
     return $response;
 }
开发者ID:ppy,项目名称:osu-web,代码行数:19,代码来源:TurbolinksSupport.php

示例7: includeArtMeta

 public function includeArtMeta(ContestEntry $entry)
 {
     if ($entry->contest->type !== 'art' || !presence($entry->entry_url)) {
         return $this->item($entry, function ($entry) {
             return [];
         });
     }
     return $this->item($entry, function ($entry) {
         $size = fast_imagesize($entry->entry_url);
         return ['width' => $size[0], 'height' => $size[1]];
     });
 }
开发者ID:ppy,项目名称:osu-web,代码行数:12,代码来源:ContestEntryTransformer.php

示例8: handle

 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle(Request $request, Closure $next)
 {
     $locale = presence($request->input('locale')) ?? presence($request->cookie('locale')) ?? locale_accept_from_http($request->server('HTTP_ACCEPT_LANGUAGE'));
     $locale = get_valid_locale($locale);
     App::setLocale($locale);
     $response = $next($request);
     if (method_exists($response, 'withCookie')) {
         return $response->withCookie(cookie()->forever('locale', $locale));
     } else {
         return $response;
     }
 }
开发者ID:ameliaikeda,项目名称:osu-web,代码行数:20,代码来源:SetLocale.php

示例9: featured

 public function featured()
 {
     $featuredStreamId = presence((string) Cache::get(static::FEATURED_CACHE_KEY));
     if ($featuredStreamId !== null) {
         foreach ($this->all() as $stream) {
             if ((string) $stream->_id !== $featuredStreamId) {
                 continue;
             }
             $featuredStream = $stream;
             break;
         }
     }
     return $featuredStream ?? null;
 }
开发者ID:ameliaikeda,项目名称:osu-web,代码行数:14,代码来源:LivestreamCollection.php

示例10: verify

 public function verify($username, $password)
 {
     $hash = Request::input('hash');
     $credentials = ['username' => $username, 'password' => $password];
     if (presence($hash) && $hash === 'md5') {
         // prehashed, we want to skip the md5 step of OsuHasher
         $user = User::where('username', $username)->first();
         if (password_verify($password, $user->getAuthPassword())) {
             return $user->user_id;
         }
     } else {
         if (Auth::once($credentials)) {
             return Auth::user()->user_id;
         }
     }
     return false;
 }
开发者ID:ameliaikeda,项目名称:osu-web,代码行数:17,代码来源:OAuth2PasswordGrantVerifier.php

示例11: store

 public function store()
 {
     if (Request::hasFile('cover_file') !== true) {
         abort(422);
     }
     $topic = null;
     if (presence(Request::input('topic_id')) !== null) {
         $topic = Topic::findOrFail(Request::input('topic_id'));
         priv_check('ForumTopicEdit', $topic)->ensureCan();
         if ($topic->cover !== null) {
             abort(422);
         }
     }
     try {
         $cover = TopicCover::upload(Request::file('cover_file')->getRealPath(), Auth::user(), $topic);
     } catch (ImageProcessorException $e) {
         return error_popup($e->getMessage());
     }
     return json_item($cover, new TopicCoverTransformer());
 }
开发者ID:ameliaikeda,项目名称:osu-web,代码行数:20,代码来源:TopicCoversController.php

示例12: search

 public function search()
 {
     $current_user = Auth::user();
     $params = [];
     if (is_null($current_user)) {
         $params = ['page' => Request::input('page')];
     } else {
         $params = ['query' => Request::input('q'), 'mode' => Request::input('m'), 'status' => Request::input('s'), 'genre' => Request::input('g'), 'language' => Request::input('l'), 'extra' => array_filter(explode('-', Request::input('e')), 'strlen'), 'rank' => array_filter(explode('-', Request::input('r')), 'strlen'), 'page' => Request::input('page'), 'sort' => explode('_', Request::input('sort'))];
         if (!$current_user->isSupporter()) {
             unset($params['rank']);
         }
     }
     $params = array_filter($params, function ($v, $k) {
         if (is_array($v)) {
             return !empty($v);
         } else {
             return presence($v) !== null;
         }
     }, ARRAY_FILTER_USE_BOTH);
     $beatmaps = BeatmapSet::search($params);
     return fractal_collection_array($beatmaps, new BeatmapSetTransformer(), 'difficulties');
 }
开发者ID:Bobo1239,项目名称:osu-web,代码行数:22,代码来源:BeatmapController.php

示例13: store

 public function store()
 {
     if (Request::hasFile('cover_file') !== true) {
         abort(422);
     }
     $topic = null;
     if (presence(Request::input('topic_id')) !== null) {
         $topic = Topic::findOrFail(Request::input('topic_id'));
         $this->authorizePost($topic->forum, $topic);
         if ($topic->canBeEditedBy(Auth::user()) !== true) {
             abort(403);
         }
         if ($topic->cover !== null) {
             abort(422);
         }
     }
     try {
         $cover = TopicCover::upload(Request::file('cover_file')->getRealPath(), Auth::user(), $topic);
     } catch (ImageProcessorException $e) {
         return error_popup($e->getMessage());
     }
     return fractal_item_array($cover, new TopicCoverTransformer());
 }
开发者ID:nanaya,项目名称:osu-web,代码行数:23,代码来源:TopicCoversController.php

示例14: search

 public function search()
 {
     $current_user = Auth::user();
     if (is_null($current_user)) {
         $data = new Collection([]);
     } else {
         $params = ['query' => Request::input('q'), 'mode' => Request::input('m'), 'status' => Request::input('s'), 'genre' => Request::input('g'), 'language' => Request::input('l'), 'extra' => array_filter(explode('-', Request::input('e')), 'strlen'), 'rank' => array_filter(explode('-', Request::input('r')), 'strlen'), 'page' => Request::input('page'), 'sort' => explode('_', Request::input('sort'))];
         if (!$current_user->isSupporter()) {
             unset($params['rank']);
         }
         $params = array_filter($params, function ($v, $k) {
             if (is_array($v)) {
                 return !empty($v);
             } else {
                 return presence($v) !== null;
             }
         }, ARRAY_FILTER_USE_BOTH);
         $data = new Collection(BeatmapSet::search($params), new BeatmapSetTransformer());
     }
     $fractal = new Manager();
     $beatmaps = $fractal->createData($data)->toArray();
     return $beatmaps;
 }
开发者ID:nanaya,项目名称:osu-web,代码行数:23,代码来源:BeatmapController.php

示例15: arrayBeatmapSet

 public function arrayBeatmapSet($matches)
 {
     $beatmapSetTitle = presence($matches['beatmapSetTitle'], '(no title)');
     return ['title' => html_entity_decode($beatmapSetTitle), 'url' => html_entity_decode($matches['beatmapSetUrl'])];
 }
开发者ID:nanaya,项目名称:osu-web,代码行数:5,代码来源:Event.php


注:本文中的presence函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。