我想id在点击它时对表格进行排序.它正在工作,但主要的是引导箭头上下图标也应该附加到id标签上.
当数据以降序显示时,arrow-bottom应显示引导程序图标,当数据按升序显示时,arrow-up应显示图标.
UsersController.php
public $paginate = array('limit'=>4);
public function index() {
$this->User->recursive = 0;
$this->set('users', $this->paginate());
}
Run Code Online (Sandbox Code Playgroud)
index.ctp
<div class="users index">
<h2><?php echo __('Users'); ?></h2>
<table class="zebra-striped table-bordered " cellpadding="0" cellspacing="0">
<tr>
<th>
<a href='' >
<?php echo $this->Paginator->sort('id'); ?>
<i class='icon-arrow-up'></i>
</a>
</th>
<th><a href='' >First Name <i class='icon-arrow-down'></i>
</a> </th>
<th>Last Name <i class='icon-resize-full'></i></a></th>
</tr>
<?php foreach ($users as $user): ?>
<tr>
<td><?php echo h($user['User']['id']); ?> </td>
<td><?php echo h($user['User']['first_name']); ?> </td> …Run Code Online (Sandbox Code Playgroud) 我想创建带有自定义验证错误消息的自定义验证规则.为此,我创建了一条规则:
$rule => [
'app_id' => 'isValidTag'
]
Run Code Online (Sandbox Code Playgroud)
并为自定义消息:
$message => [
app_id.isValidTag => 'Not a Valid id'
];
Run Code Online (Sandbox Code Playgroud)
之后我创建了服务提供商:
class CustomValidationServiceProvider extends ServiceProvider
{
public function boot() {
//parent::boot();
$this->app->validator->resolver(function($transator,$data,$rules,$messages){
return new CustomValidator($transator,$data,$rules,$messages);
});
}
}
Run Code Online (Sandbox Code Playgroud)
我的自定义验证类是:
class CustomValidator extends Validator {
if(empty($parameters)) {
return true;
}
$conext = $parameters[0];
$tag = Tag::where('id', $value)->where('context', $conext)->get();
$flag = false;
if($tag->count() > 0) {
$flag = true;
}
return $flag;
}
Run Code Online (Sandbox Code Playgroud)
一切正常,但问题是我的自定义消息app_id.isValidTag是不工作,即使所有其他消息都正常工作.
请建议我在这里或Laravel 5.2中遗漏的内容,显示消息有一些变化.任何想法将不胜感激.