student.php 961 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace Appaaa;
  3. use Illuminate\Database\Eloquent\Model;
  4. $aa = "bb";
  5. return;
  6. class Student extends Model
  7. {
  8. //指定表名 默认 模型名的复数
  9. protected $table = 'student';
  10. //指定主键 默认主键 为ID
  11. protected $primaryKey = 'id';
  12. //指定允许批量赋值的字段
  13. protected $fillable = ['name', 'age'];
  14. //指定不允许批量赋值的字段
  15. protected $guarded = [];
  16. //是否维护时间戳 默认维护
  17. //$timestamps=falst 不维护
  18. public $timestamps = true;
  19. //维护时间的时候保存时间戳
  20. protected function getDateFormat()
  21. {
  22. return time(); // TODO: Change the autogenerated stub
  23. }
  24. //查询的时候返回时间戳
  25. protected function asDateTime($value)
  26. {
  27. // return parent::asDateTime($value); // TODO: Change the autogenerated stub
  28. return $value;
  29. }
  30. }
  31. $students=Student::all();
  32. dd($students);