12345678910111213141516171819202122232425 |
- <?php
- namespace App\Models\Course;
- use Carbon\Carbon;
- use Illuminate\Database\Eloquent\Model;
- use DateTimeInterface;
- class Cate extends Model
- {
- protected $connection = 'mysql_c';
- protected $table='cate';
- protected $guarded=[];
- protected function serializeDate(DateTimeInterface $date): string
- {
- return $date->format('Y-m-d H:i:s');
- }
- public function getCreatedAtAttribute($value){
- return Carbon::createFromFormat('Y-m-d H:i:s', $value)->diffForHumans();
- }
- public function course(){
- return $this->hasMany(Course::class,'c_id','id');
- }
- }
|