Share.php 654 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace App\Models\Course;
  3. use Illuminate\Database\Eloquent\Model;
  4. use DateTimeInterface;
  5. class Share extends Model
  6. {
  7. protected $connection = 'mysql_c';
  8. protected $table='share';
  9. protected $guarded=[];
  10. protected function serializeDate(DateTimeInterface $date): string
  11. {
  12. return $date->format('Y-m-d H:i:s');
  13. }
  14. public function user(){
  15. return $this->hasOne(App\Models\User::class,'id','user_id')->withTrashed();
  16. }
  17. public function course(): \Illuminate\Database\Eloquent\Relations\HasOne
  18. {
  19. return $this->hasOne(Course::class,'id','course_id','deleted_at')->withTrashed();
  20. }
  21. }