Like.php 569 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace App\Models\Wetalk;
  3. use Illuminate\Database\Eloquent\Model;
  4. use DateTimeInterface;
  5. use App\Models\User;
  6. class Like extends Model
  7. {
  8. protected $connection = 'mysql_t';
  9. protected $table='like';
  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 user(){
  16. return $this->hasOne(User::class,'id','user_id');
  17. }
  18. public function article(){
  19. return $this->hasOne(Article::class,'id','article_id');
  20. }
  21. }