Comment.php 660 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 Comment extends Model
  7. {
  8. protected $connection = 'mysql_t';
  9. protected $table='comment';
  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. // $instance = new User;
  17. // $instance->setConnection('mysql');
  18. // $query = $instance->newQuery();
  19. // return $this->hasOne($query, $this,'id','user_id');
  20. return $this->hasOne('App\Models\User','id','user_id');
  21. }
  22. }