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


PHP Board::find方法代码示例

本文整理汇总了PHP中Board::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Board::find方法的具体用法?PHP Board::find怎么用?PHP Board::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Board的用法示例。


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

示例1: get_view

 /**
  * View a board
  *
  * List all the threads in the board
  */
 public function get_view($board_id)
 {
     // get all the threads for this board
     $threadlist = DB::table('threads')->join('users', 'threads.user_id', '=', 'users.id')->where('threads.board_id', '=', $board_id)->order_by('threads.updated_at', 'desc')->paginate(10, array('threads.id', 'threads.user_id', 'threads.subject', 'threads.postcount', 'threads.created_at', 'users.username'));
     // get this board
     $board = Board::find($board_id);
     return View::make('thread-list')->with('threadlist', $threadlist)->with('board', $board);
 }
开发者ID:nickfun,项目名称:funbb,代码行数:13,代码来源:board.php

示例2: getPost

 public function getPost($postId)
 {
     // board
     $b = \Board::find($postId);
     if ($b === NULL) {
         return \Redirect::route('frontend.board.list');
     }
     $b->count_num = $b->count_num + 1;
     $b->save();
     $b->d = str_replace('-', '/', substr($b->created_at, 0, 10));
     $isShowPost = false;
     if ($b->isPrivate == '0') {
         $isShowPost = true;
     } else {
         $user_id = \Auth::check() ? \Auth::user()->id : null;
         $isShowPost = $user_id === $b->user_id && $user_id !== null;
     }
     // fetch reply
     $br = \BoardReply::where('board_id', '=', $postId)->orderBy('created_at', 'desc')->first(array('tags', 'content', \DB::raw("date_format(created_at,'%Y/%m/%d') as d")));
     $tags = array();
     if ($br !== null) {
         $tagsId = unserialize($br->tags);
         $tags = \ServiceFaq::find($tagsId, array('id', 'title'));
     }
     // get next and previous
     $sql = 'select * from ' . '(select id, topic, created_at from board where created_at < ? and status = "1" order by created_at desc limit 0, 1) as T ' . 'union select * from ' . '(select id, topic, created_at from board where created_at > ? and status = "1" order by created_at asc limit 0, 1) as T order by id asc';
     $rows = \DB::select($sql, array($b->created_at, $b->created_at));
     $list = array('next' => null, 'prev' => null);
     foreach ($rows as &$r) {
         if ($r->created_at > $b->created_at) {
             $list['next'] = $r;
         }
         if ($r->created_at < $b->created_at) {
             $list['prev'] = $r;
         }
     }
     return \View::make('aesthetics.board.view_post', array('board' => &$b, 'list' => &$list, 'reply' => &$br, 'tags' => &$tags, 'isShowPost' => $isShowPost));
 }
开发者ID:kettanyam,项目名称:20141001done,代码行数:38,代码来源:BoardController.php

示例3: showBoard

 public function showBoard($id)
 {
     $posts = array();
     $client = new \GuzzleHttp\Client();
     $count = 0;
     $board = Board::find($id);
     $hashtag = $board->hashtag;
     $config = $board->config()->first();
     $instagramKey = Config::get('laravel-social::providers.instagram.client_id');
     $googleKey = 'AIzaSyDiywW3UvpbQ5aR7f_8tLVgNCzui7Gq6ek';
     $postCount = 20;
     $googleToken = '';
     $instagramNextMaxId = '';
     $instagramMinTagId = '';
     $twitterMaxId = '';
     $twitterSinceId = '';
     $facebookSinceId = '';
     $facebookUntilId = '';
     $vineSinceId = '';
     $googleSinceId = '';
     if ($config->has_insta != -1) {
         if (Auth::check()) {
             $user = Auth::user();
             $provider = SocialProvider::where('user_id', '=', $user->id)->where('provider', '=', 'instagram')->first();
             if (is_null($provider)) {
                 $instagram = $client->get('https://api.instagram.com/v1/tags/' . $hashtag . '/media/recent?count=' . $postCount . '&client_id=' . $instagramKey);
             } else {
                 $token = $provider->access_token;
                 $instagram = $client->get('https://api.instagram.com/v1/tags/' . $hashtag . '/media/recent?count=' . $postCount . '&access_token=' . $token);
             }
         } else {
             $provider = SocialProvider::where('user_id', '=', $config->user_id)->where('provider', '=', 'instagram')->first();
             if (is_null($provider)) {
                 $instagram = $client->get('https://api.instagram.com/v1/tags/' . $hashtag . '/media/recent?count=' . $postCount . '&client_id=' . $instagramKey);
             } else {
                 $token = $provider->access_token;
                 $instagram = $client->get('https://api.instagram.com/v1/tags/' . $hashtag . '/media/recent?count=' . $postCount . '&access_token=' . $token);
             }
         }
         if ($instagram->getStatusCode() == 200) {
             $instagramData = $instagram->json();
             foreach ($instagramData['data'] as $data) {
                 if (strpos($data['caption']['text'], $hashtag) !== false) {
                     $post['user_id'] = $data['caption']['from']['id'];
                     $post['username'] = $data['caption']['from']['username'];
                     $post['url'] = $data['link'];
                     $str = $data['caption']['text'];
                     $str = preg_replace('/@([\\w-]+)/i', '', $str);
                     // #@
                     $post['caption'] = $str;
                     $post['post_id'] = $data['id'];
                     $post['vendor'] = 'instagram';
                     $post['user_img_url'] = $data['caption']['from']['profile_picture'];
                     $post['date_created'] = date("m-d-y H:i:s", $data['created_time']);
                     if (isset($data['images']) && !isset($data['videos'])) {
                         $post['img_url'] = $data['images']['standard_resolution']['url'];
                         $post['post_type'] = 'image';
                     } else {
                         if (isset($data['videos'])) {
                             //	dd($data['videos']);
                             $post['img_url'] = $data['images']['standard_resolution']['url'];
                             $post['embed'] = $data['videos']['standard_resolution']['url'];
                             $post['post_type'] = 'video';
                         }
                     }
                     array_push($posts, $post);
                     $count++;
                 }
             }
             if (isset($instagramData['pagination']['next_max_id'])) {
                 $instagramNextMaxId = $instagramData['pagination']['next_max_id'];
             }
             if (isset($instagramData['pagination']['min_tag_id'])) {
                 $instagramMinTagId = $instagramData['pagination']['min_tag_id'];
             }
         }
     }
     if ($config->has_fb == 9999) {
         $facebook = Facebook::api('/search?type=post&limit=' . $postCount . '&q=%23' . $hashtag);
         if ($facebook) {
             foreach ($facebook['data'] as $post) {
                 $post['vendor'] = 'facebook';
                 $post['post_id'] = $post['id'];
                 //$post['url'] = $post['link'];
                 $post['user_id'] = $post['from']['id'];
                 $post['username'] = $post['from']['name'];
                 $post['user_img_url'] = 'https://graph.facebook.com/' . $post['from']['id'] . '/picture?type=small';
                 if ($post['type'] == 'photo') {
                     $post['img_url'] = $post['picture'];
                     $post['post_type'] = 'image';
                 } else {
                     if ($post['type'] == 'video' && isset($post['picture'])) {
                         $post['post_type'] = 'video';
                         $post['img_url'] = $post['picture'];
                         $post['embed'] = $post['link'];
                     } else {
                         $post['post_type'] = 'text';
                     }
                 }
                 if (isset($post['message'])) {
//.........这里部分代码省略.........
开发者ID:itsfamestudio,项目名称:hashtag,代码行数:101,代码来源:AjaxController.php

示例4: showBoardSettings

 public function showBoardSettings($hashtag, $id)
 {
     if (Auth::check() && isset($hashtag) && isset($id)) {
         $user = Auth::user();
         $board = Board::find($id);
         if ($board) {
             if ($board->config()->first()->user_id == $user->id) {
                 $data['config'] = $board->config()->first();
                 $data['board'] = $board;
                 $data['user'] = $user;
                 $data['title'] = $this->layout->title = 'Ustawienia #' . $board->hashtag;
                 $this->layout->content = View::make('user.board-settings', $data);
             } else {
                 return Redirect::to('/konto')->with('alert', array('type' => 'error', 'content' => 'Błąd! Coś poszło nie tak.'));
             }
         } else {
             return Redirect::to('/konto')->with('alert', array('type' => 'error', 'content' => 'Błąd! Coś poszło nie tak.'));
         }
     } else {
         return Redirect::to('/')->with('alert', array('type' => 'error', 'content' => 'Błąd! Coś poszło nie tak.'));
     }
 }
开发者ID:itsfamestudio,项目名称:hashtag,代码行数:22,代码来源:UserController.php

示例5: postStatus

 public function postStatus()
 {
     try {
         $board_id = Arr::get($_POST, 'board_id', null);
         //update status of board
         $b = Board::find($board_id);
         if ($b === null) {
             throw new Exception('Request ID of board error!');
         }
         $b->status = $b->status == '0' ? '1' : '0';
         $b->save();
         $topic = mb_substr($b->topic, 0, 10);
         $topic .= mb_strlen($b->topic, 'UTF-8') > 10 ? '...' : '';
         $message = sprintf('更新留言「%s」的狀態,成功!', $topic);
         return Response::json(array('status' => 'ok', 'value' => $b->status, 'message' => $message, '_token' => csrf_token()));
     } catch (Exception $e) {
         return Response::json(array('status' => 'error', 'value' => 1, 'message' => $e->getMessage(), '_token' => csrf_token()));
     }
 }
开发者ID:kettanyam,项目名称:20141001done,代码行数:19,代码来源:BoardController.php

示例6: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $records = ApplyRecord::orderBy('created_at', 'desc')->orderBy('id', 'desc');
     if (Input::has('fields')) {
         $fields = explode(',', Input::get('fields'));
         $records = $records->select($fields);
     }
     if (Input::has('list')) {
         $list = explode(',', Input::get('list'));
         $records = $records->whereIn('id', $list);
     }
     if (Input::has('user_list')) {
         $list = explode(',', Input::get('user_list'));
         $records = $records->whereIn('user_id', $list);
     }
     if (Input::has('board_list')) {
         $list = explode(',', Input::get('board_list'));
         foreach ($list as $key => $value) {
             if (!is_numeric($value)) {
                 $board = Board::where('code', $value)->first();
                 if ($board != null) {
                     $list[$key] = $board->id;
                 } else {
                     unset($list[$key]);
                 }
             }
         }
         $records = $records->whereIn('board_id', $list);
     }
     if (Input::has('type_list')) {
         $list = explode(',', Input::get('type_list'));
         var_dump($list);
         $records = $records->whereIn('event_type', $list);
     }
     if (Input::has('from') or Input::has('end')) {
         $from = Input::get('from', date('Y-m-d'));
         $end = Input::get('end', date('Y-m-d'));
         $records = $records->where(function ($records) use($from, $end) {
             $records->orWhereRaw("('{$from}' between `post_from` AND `post_end`)")->orWhereRaw("('{$end}'  between `post_from` AND `post_end`)")->orWhereRaw("'{$from}' <= `post_from` AND `post_end` <= '{$end}'");
         });
     }
     if (Input::has('date_list')) {
         $list = explode(',', Input::get('date_list'));
         $records = $records->where(function ($records) use($list) {
             foreach ($list as $date) {
                 if (strtotime($date)) {
                     $date = date('Y-m-d', strtotime($date));
                     $records = $records->orWhereRaw("('{$date}' between `post_from` AND `post_end`)");
                 }
             }
         });
     }
     if (Input::has('limit')) {
         $limit = Input::get('limit');
         $offset = Input::get('offset', 0);
         $records = $records->skip($offset)->take($limit)->get();
     } else {
         $records = $records->get();
     }
     foreach ($records as $key => $record) {
         $board = Board::find($record['board_id']);
         $user = User::find($record['user_id']);
         $type_mapping = Config::get('poster.name_mapping.event_types');
         $record->event_type_name = $type_mapping[$record->event_type];
         $record->board_code = $board->code;
         $record->username = $user->username;
         $record->user_title = $user->title;
     }
     return Response::json($records);
 }
开发者ID:fntsrlike,项目名称:BoardsManager,代码行数:75,代码来源:ApplyRecordController.php

示例7: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $rules = array('description' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Response::json(['success' => false, 'messages' => $validator->errors()]);
     }
     $board = Board::find($id)->update(['description' => Input::get('description')]);
     return Response::json(['success' => true]);
 }
开发者ID:fntsrlike,项目名称:BoardsManager,代码行数:16,代码来源:BoardController.php

示例8: showBoard

 public function showBoard($query, $id = NULL, $presentation = NULL)
 {
     Asset::add('//cdnjs.cloudflare.com/ajax/libs/jquery.isotope/2.0.0/isotope.pkgd.min.js', 'footer');
     Asset::add('//cdnjs.cloudflare.com/ajax/libs/jquery.imagesloaded/3.0.4/jquery.imagesloaded.min.js', 'footer');
     Asset::add('/js/libs/jquery.dropdown.js', 'footer');
     //Asset::add('/js/posts.js', 'footer');
     Asset::add('/js/posts-new.js', 'footer');
     //check if board exists
     if (strlen($query) > 2) {
         $query = explode(' ', trim($query));
         $result = preg_replace('/#([\\w-]+)/i', '$1', $query[0]);
         $query = Sanitize::string($result);
     } else {
         App::abort(404);
     }
     if (isset($id)) {
         $board = Board::find($id);
         if (!is_null($board)) {
             if ($board->hashtag != $query || $board->config()->first()->user_id == 0) {
                 App::abort(404);
             }
         } else {
             App::abort(404);
         }
     } else {
         $board = Board::where('hashtag', '=', $query)->whereHas('config', function ($q) {
             $q->where('user_id', '=', 0);
         })->first();
         if (is_null($board)) {
             $board = Board::create(array('hashtag' => $query));
             $visit = Visit::create(array('ip' => Request::ip()));
             $config = BoardConfig::create(array('board_id' => $board->id));
         }
     }
     if ($board->config()->first()->is_active == 1) {
         if (!is_null($board->cover_file_name)) {
             $data['layout'] = $this->layout->cover = 'with-cover';
         } else {
             $data['layout'] = $this->layout->cover = 'no-cover';
         }
         if (Auth::check()) {
             $user = Auth::user();
             $data['username'] = preg_replace('/@.*?$/', '', $user->email);
             $data['userBoards'] = Board::byUserId($user)->orderBy('created_at', 'asc')->get();
             $data['user'] = $user;
             if ($user->id == $board->config()->first()->user_id) {
                 $userOwned = true;
             }
             if (!is_null($user->provider()->first()) && $user->provider()->first()->provider == 'facebook') {
                 $data['avatar'] = '<img src="http://graph.facebook.com/' . $user->provider()->first()->provider_id . '/picture?type=small" alt="avatar" />';
             }
         }
         if (Session::get('session-stat') != $board->id) {
             $stats = Stat::firstOrCreate(array('board_id' => $board->id))->increment('hits');
             Session::put('session-stat', $board->id);
         }
         $data['board'] = $board;
         $data['boardData'] = $this->layout->boardData = $board;
         $data['title'] = $this->layout->title = $board->hashtag;
         $data['bodyClass'] = $this->layout->bodyClass = $board->hashtag . (isset($userOwned) ? ' user-owned' : '');
         if (isset($presentation) && $presentation != 'live') {
             App::abort(404);
         }
         if (isset($id) && $presentation == 'live' && $board->config()->first()->presentation == 1) {
             $data['bodyClass'] = $this->layout->bodyClass = $board->hashtag . (isset($userOwned) ? ' user-owned' : '') . ' board-presentation';
             $this->layout->content = View::make('boards.board-presentation', $data);
         } else {
             $this->layout->content = View::make('boards.index', $data);
         }
     } else {
         App::abort(404);
     }
 }
开发者ID:itsfamestudio,项目名称:hashtag,代码行数:73,代码来源:BoardsController.php


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