久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網
      最全最豐富的資訊網站

      Laravel中的一些常用模型屬性介紹

      本篇文章給大家介紹一些Laravel中常用模型屬性。有一定的參考價值,有需要的朋友可以參考一下,希望對大家有所幫助。

      Laravel中的一些常用模型屬性介紹

      $connection

       /**   * 為模型指定一個連接名稱。   *   * @var string   */  protected $connection = 'connection-name';

      $table

      /**  * 為模型指定一個表名。  *  * @var string  */  protected $table = 'users';

      $primaryKey

      /**  * 為模型指定主鍵。  *  * @var string  */  protected $primaryKey = 'user_id';

      $keyType

       /**   * 自定義主鍵類型。   *   * @var string   */  protected $keyType = 'string';

      $incrementing

       /**   * 如果使用的是非遞增或者非數字的主鍵。   *   * @var bool   */  public $incrementing = false;

      $with

      class Post extends Model {  /**   * 加載模型關聯(lián)數據。   *    * @var array   */   protected $with = [       'comments'   ]; }

      $withCount

      class Post extends Model {  /**   * 加載模型關聯(lián)數據數量。   *    * @var array   */   protected $withCount = [       'comments'   ]; }

      $timestamps

       /**   * 執(zhí)行模型是否自動維護時間戳.   *   * @var bool   */  public $timestamps = false;

      注:guarded 與 fillable,在當前模型中只能存在一者噢。

      $fillable

      /**  * 可以被批量賦值的屬性。  *  * @var array  */  protected $fillable = ['name', 'age'];

      $guarded

       /**   * 不可被批量賦值的屬性,當 $guarded 為空數組時則所有屬性都可以被批量賦值。   *   * @var array   */  protected $guarded = ['price'];

      CREATED_AT

       /**   * 創(chuàng)建時間戳字段名稱。   *   * @var string   */  const CREATED_AT = 'created_at';

      UPDATED_AT

       /**   * 更新時間戳字段名稱。   *   * @var string   */  const UPDATED_AT = 'updated_at';

      $attributes

       const STATUS_CREATED = 'created';   /**   * 給定字段默認值。   *   * @var array   */  protected $attributes = [      'status' => self::STATUS_CREATED,  ];

      $casts

       /**   * 字段轉換為對應的類型。   *   * @var array   */  protected $casts = [     'id' => 'integer',     'settings' => 'array',     'is_admin' => 'boolean',  ];

      $dates

       /**   * 需要轉換成日期的屬性。   *   * @var array   */  protected $dates = ['deleted_at'];

      $dateFormat

       /**   * 模型中日期字段的保存格式。   *   * @var string   */  protected $dateFormat = 'U';

      不清楚 U 是什么意思的,請看 Date/Time 函數 。

      $appends

       /**   * 追加到模型數組表單的訪問器。   *   * @var array   */  protected $appends = ['is_admin'];

      一般情況下 appends 都是與 訪問器 連用的。

      $hidden

       /**   * 數組中的屬性會被隱藏。   *   * @var array   */  protected $hidden = ['password'];

      $visible

       /**   * 數組中的屬性會被展示。   *   * @var array   */  protected $visible = ['first_name', 'last_name'];

      $dispatchesEvents

       /**   * 模型的事件映射。   *   * @var array   */  protected $dispatchesEvents = [      'saved' => UserSaved::class,      'deleted' => UserDeleted::class,  ];

      $forceDeleting

       /**   * 指示模型當前是否強制刪除。   *   * @var bool   */  protected $forceDeleting = false;

      $perPage

       /**   * 默認分頁數量。   *   * @var int   */  protected $perPage = 50;

      $touches

      /**   * 更新添加的關聯(lián)模型的 updated_at 字段。   *   * @var array   */  protected $touches = ['post'];

      贊(0)
      分享到: 更多 (0)
      網站地圖   滬ICP備18035694號-2    滬公網安備31011702889846號