use a custom validation scenario in the controller, but how to use the custom error prompt in the scenario
use a custom validation scenario in the controller, but how to use the custom error prompt in the scenario
protected $rule = [
'name' => 'require|max:25',
'age' => 'number|between:1,120',
'email' => 'email',
];
protected $message = [
'name.require' => '',
'name.max' => '25',
'age.number' => '',
'age.between' => '1-120',
'email' => '',
];
protected $scene = [
'edit' => ['name','age'],
];
tp5.1 https://www.kancloud.cn/manua.
tp5.0 https://www.kancloud.cn/manua.
documents are all written in message.
take a good look at the manual
Previous: How to set url position and bg-size? for the CSS background property
Next: Js loop object array adding elements to a new array one by one
I set up User.php, User.php under the model layer and have a method getUserInfo to query the data, as follows: $userModel = new UserModel; dump($userModel->getUser()); dump(json_encode($userModel->getUser())); the first printed data is as follo...
follow the ThinkPHP5.0 official manual prompt: User::event( before_insert , function ($user) { if ($user->status != 1) { return false; } }); :https: www.kancloud.cn manua... TP beforeInsert ,,,,. the direct insertion is s...
situation description: A Table: user s coupon Information Table, Field: id,ticket_id,status B Table: voucher Information Table, Field: id,ticket_info,status in Model A, there is the following code: class An extend Model { public function getUserTi...
Please take a look. Is it wrong to write this? why can t you parse this variable ? ...
browser error: SQLSTATE [HY000] [1045] Access denied for user root @ localhost (using password: NO) I successfully connected to the database with navicat, the user name is root, password is the password set when installing mysql, and the framework...
check whether to log in in the check class file under the behavior file under the module, and then jump to the business, use the redirect prompt to report an error, and find the answer Call to undefined method app admin behavior CheckBehavior::redir...
all controllers of my background module admin, need operation authentication, or build operation menus, or other common operations on the premise of ignoring the intermediate key: my previous way of writing is to write a "master " controller common...
how to realize the if judgment of mysql. There is now a table with two key fields SELECT * FROM house WHERE price= 8500 OR shoufu= 30 I think, when the $price passed in by php is empty, the sql search statement is SELECT * FROM house WHERE s...
Why does thinkphp5 always report errors when uploading multiple files using the multiple attribute? error message: HTML Code: <input name="file" type="file" multiple > <input type="submit" value=""...
$this- > request- > isPost () uses $.post (target, query) .success (function (data) { in receiving empty data to report the following error Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version....
A simple post request, which was normal before, suddenly went wrong. As thinkphp5.0 is not very familiar with it, it should not be a big problem. I hope you will pass by and have a look. WeChat Mini Programs client sends post request code, which does...
think-queue; is used in TP5, but when enabled, the Redis extension is not installed! but my extension does have I don t know why? Solve it! there s nothing wrong with the environment variable! ...
for business reasons, you need to bind different modules to different domain names in the tp5 framework. now, for example, www.test.com has entered the index controller index method in the hkfc module. but the second * .test.com does not work, for ...
var token = localStorage.getItem( userToken ); if(!token){ alert( ); return false; } var ws = new WebSocket("ws: 127.0.0.1:8081"); when ws.onopen, I intend to send token to the server for verification, but it...
TP5 model queries with the field () method have a field that does not display Commodity table model ** * * * @return think model relation HasMany * public function goodsComment() { return $this->hasMany( Ma...
foreground code $.ajax({ type: POST , url: __URL__ add , data:{content:data} }); data is an array $data $_REQUEST ajax ...
recently used the queue, used the official queue package top-think think-queue , successfully wrote the data into the queue after installation, but went to the consumption queue, that is, when using php think queue:work-- queue xxx, prompted that the c...
learn to use Tp5.1 when looking at other people s code, I think a lot of operations about the database are written into the controller; public function save() { $data = input( post ); $validate = $this->validate($data,"app commo...
for example, the array is like this $data = [ [ mobile => 1 , price => 100.00 ], [ mobile => 2 , price => 500.00 ], ]; one-dimensional array can be verified di...
I installed carbon, with composer and got an error when using it: fatal error: Class CarbonCarbon not found I installed it using composer require nesbot carbon. The directory structure after installation is as follows: Do you want to set some...