fix bug of total pages on skinlib
This commit is contained in:
parent
fca201178a
commit
f2c1c4a851
@ -33,22 +33,30 @@ class SkinlibController extends BaseController
|
||||
$query->where('public', '=', '1')
|
||||
->where('type', '=', 'steve')
|
||||
->orWhere('type', '=', 'alex');
|
||||
})->orderBy($sort_by, 'desc')->skip(($page - 1) * 20)->take(20)->get();
|
||||
})->orderBy($sort_by, 'desc');
|
||||
$total_pages = ceil($textures->count() / 20);
|
||||
$textures = $textures->skip(($page - 1) * 20)->take(20)->get();
|
||||
} elseif ($filter == "user") {
|
||||
$uid = isset($_GET['uid']) ? $_GET['uid'] : 0;
|
||||
|
||||
if ($uid == $this->user->uid) {
|
||||
// show private textures when show uploaded textures of current user
|
||||
$textures = Texture::where('uploader', $uid)->orderBy($sort_by, 'desc')->skip(($page - 1) * 20)->take(20)->get();
|
||||
$textures = Texture::where('uploader', $uid)->orderBy($sort_by, 'desc');
|
||||
$total_pages = ceil($textures->count() / 20);
|
||||
$textures = $textures->skip(($page - 1) * 20)->take(20)->get();
|
||||
} else {
|
||||
$textures = Texture::where('uploader', $uid)->where('public', '1')->orderBy($sort_by, 'desc')->skip(($page - 1) * 20)->take(20)->get();
|
||||
$textures = Texture::where('uploader', $uid)->where('public', '1')->orderBy($sort_by, 'desc');
|
||||
$total_pages = ceil($textures->count() / 20);
|
||||
$textures = $textures->skip(($page - 1) * 20)->take(20)->get();
|
||||
}
|
||||
|
||||
} else {
|
||||
$textures = Texture::where('type', $filter)->where('public', '1')->orderBy($sort_by, 'desc')->skip(($page - 1) * 20)->take(20)->get();
|
||||
$textures = Texture::where('type', $filter)->where('public', '1')->orderBy($sort_by, 'desc');
|
||||
$total_pages = ceil($textures->count() / 20);
|
||||
$textures = $textures->skip(($page - 1) * 20)->take(20)->get();
|
||||
}
|
||||
|
||||
$total_pages = ceil(count($textures) / 20);
|
||||
|
||||
|
||||
echo View::make('skinlib.index')->with('user', $this->user)
|
||||
->with('sort', $sort)
|
||||
|
@ -94,7 +94,11 @@ class User
|
||||
|
||||
public function getNickName()
|
||||
{
|
||||
return ($this->eloquent_model->nickname == "") ? $this->email : $this->eloquent_model->nickname;
|
||||
if (!$this->is_registered) {
|
||||
return "不存在的用户";
|
||||
} else {
|
||||
return ($this->eloquent_model->nickname == "") ? $this->email : $this->eloquent_model->nickname;
|
||||
}
|
||||
}
|
||||
|
||||
public function setNickName($new_nickname)
|
||||
|
@ -106,6 +106,23 @@
|
||||
<a href="javascript:deleteTexture({{ $texture->tid }});" class="btn btn-danger pull-right">删除材质</a>
|
||||
</div><!-- /.box-footer -->
|
||||
</div><!-- /.box -->
|
||||
@elseif ($user->is_admin)
|
||||
<div class="box box-danger">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">管理员面板</h3>
|
||||
</div><!-- /.box-header -->
|
||||
<div class="box-body">
|
||||
<p>你可以将此材质设为隐私或删除。这将会使此材质从每一个收藏者的衣柜中移除。</p>
|
||||
</div><!-- /.box-body -->
|
||||
<div class="box-footer">
|
||||
@if ($texture->public == "1")
|
||||
<a href="javascript:changePrivacy({{ $texture->tid }});" class="btn btn-warning">设为隐私</a>
|
||||
@else
|
||||
<a href="javascript:changePrivacy({{ $texture->tid }});" class="btn btn-warning">设为公开</a>
|
||||
@endif
|
||||
<a href="javascript:deleteTexture({{ $texture->tid }});" class="btn btn-danger pull-right">删除材质</a>
|
||||
</div><!-- /.box-footer -->
|
||||
</div><!-- /.box -->
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user