Cate.php 604 B

12345678910111213141516171819202122232425
  1. <?php
  2. namespace App\Models\Course;
  3. use Carbon\Carbon;
  4. use Illuminate\Database\Eloquent\Model;
  5. use DateTimeInterface;
  6. class Cate extends Model
  7. {
  8. protected $connection = 'mysql_c';
  9. protected $table='cate';
  10. protected $guarded=[];
  11. protected function serializeDate(DateTimeInterface $date): string
  12. {
  13. return $date->format('Y-m-d H:i:s');
  14. }
  15. public function getCreatedAtAttribute($value){
  16. return Carbon::createFromFormat('Y-m-d H:i:s', $value)->diffForHumans();
  17. }
  18. public function course(){
  19. return $this->hasMany(Course::class,'c_id','id');
  20. }
  21. }