LinkTaskUrl.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace App\Http\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. use Illuminate\Database\Eloquent\Relations\Pivot;
  5. use Illuminate\Database\Eloquent\SoftDeletes;
  6. class LinkTaskUrl extends Model
  7. {
  8. use SoftDeletes;
  9. protected $table = 'link_tasks_url';
  10. protected $primaryKey = 'id';
  11. protected $guarded = [];
  12. protected $casts = [
  13. 'show_urls' => 'array'
  14. ];
  15. const STATUS_TITLE = [
  16. 3 => '待审核',
  17. 4 => '未通过',
  18. 5 => '已通过'
  19. ];
  20. const VALID_STATUS_TITLE = [
  21. 3 => '待检测',
  22. 4 => '网址异常',
  23. 5 => '网址正常'
  24. ];
  25. public function getStatusWithCssAttribute()
  26. {
  27. $format = '<button type="button" class="btn btn-xs btn-primary">%s</button>';
  28. switch ($this->status ?? 0) {
  29. case 3:
  30. return sprintf($format, '待审核');
  31. case 4:
  32. return sprintf($format, '未通过');
  33. case 5:
  34. return sprintf($format, '已通过');
  35. default:
  36. return '';
  37. }
  38. }
  39. public function linkDetails()
  40. {
  41. return $this->belongsTo(LinkTaskDetail::class,'link_tasks_detail_id','id');
  42. }
  43. }