<?php namespace App\Http\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\Pivot; use Illuminate\Database\Eloquent\SoftDeletes; class LinkTaskUrl extends Model { use SoftDeletes; protected $table = 'link_tasks_url'; protected $primaryKey = 'id'; protected $guarded = []; protected $casts = [ 'show_urls' => 'array' ]; const STATUS_TITLE = [ 3 => '待审核', 4 => '未通过', 5 => '已通过' ]; const VALID_STATUS_TITLE = [ 3 => '待检测', 4 => '网址异常', 5 => '网址正常' ]; public function getStatusWithCssAttribute() { $format = '<button type="button" class="btn btn-xs btn-primary">%s</button>'; switch ($this->status ?? 0) { case 3: return sprintf($format, '待审核'); case 4: return sprintf($format, '未通过'); case 5: return sprintf($format, '已通过'); default: return ''; } } public function linkDetails() { return $this->belongsTo(LinkTaskDetail::class,'link_tasks_detail_id','id'); } }