thinkphp5.1 small note

  • After acquiring the data model, without first converting attribute array, the array may be accessed by way of the direct object (inherited ArrayAccess mold), to determine what the premise is empty (isEmpty method).
  • The model output hidden, append, visible with the use of field output can be well controlled.
  • When using a model that comes with an acquisition time, it will automatically overwrite the original value to, although you can get to the original data, but sometimes both (the original data and the conversion will) need, you can define an additional getter then append acquired by the model output.
  • Using a frame validator used, if enough specifications built, customize the authentication method can be extended, may also be implemented after a predefined regular expressions called directly accumulation, such as those defined regex validator class attributes
namespace app\index\validate;

use think\Validate;

class User extends Validate
{
    protected $regex = [ 'zip' => '\d{6}'];
		
    protected $rule = [
        'name' => 'require|max:25',
	'email' => 'email',
    ];
}
// Then you can use
'zip'  => 'regex:zip'    
  • When using the authentication framework, different fields of the same scene, validation rules are different, have the scene to define methods to dynamically configure validation rules, personal feeling very easy to use.

  By Liyy

Guess you like

Origin www.cnblogs.com/widgetbox/p/12127952.html