本文整理汇总了PHP中Board::byUserId方法的典型用法代码示例。如果您正苦于以下问题:PHP Board::byUserId方法的具体用法?PHP Board::byUserId怎么用?PHP Board::byUserId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Board
的用法示例。
在下文中一共展示了Board::byUserId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showBoards
public function showBoards()
{
if (Auth::check()) {
$user = Auth::user();
$data['user'] = $user;
$data['boards'] = Board::byUserId($user);
if ($user->level == 1) {
$data['width'] = $data['boards']->count() / 1 * 100;
$data['max'] = 1;
} else {
if ($user->level == 2) {
$data['width'] = $data['boards']->count() / 5 * 100;
$data['max'] = 5;
}
}
$data['title'] = $this->layout->title = 'Tablice';
$this->layout->user = $user;
$this->layout->content = View::make('user.boards', $data);
}
}
示例2: 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);
}
}