Article.php 668 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace App\Models\Wetalk;
  3. use Illuminate\Database\Eloquent\Model;
  4. use DateTimeInterface;
  5. class Article extends Model
  6. {
  7. protected $connection = 'mysql_t';
  8. protected $table='article';
  9. protected $guarded=[];
  10. protected $appends=['all_audio'];
  11. protected function serializeDate(DateTimeInterface $date): string
  12. {
  13. return $date->format('Y-m-d H:i:s');
  14. }
  15. public function getAllAudioAttribute($key)
  16. {
  17. $domain='https://weiliao.woaidakele.cn/storage/';
  18. $audio=$this->attributes['audio'];
  19. if(!empty($audio)){
  20. return $domain.$audio;
  21. }else{
  22. return '';
  23. }
  24. }
  25. }