<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; /** * App\Models\Link * * @property int $id * @property int $is_display 是否显示(1:是,0:否) * @property int $type_id 链接分类 * @property string $link_title 链接标题 * @property string $link_url 链接地址 * @property string $link_logo 链接的LOGO * @property string|null $note 备注 * @property int $list_order 顺序 * @property int $subsite_id 分站信息(0:总站) * @property \Illuminate\Support\Carbon|null $created_at * @property \Illuminate\Support\Carbon|null $updated_at * @property string|null $deleted_at * @property-read mixed $logo_url * @property-read mixed $up_file * @property-read \App\Models\LinkCategory $show_category * @method static bool|null forceDelete() * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Link newModelQuery() * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Link newQuery() * @method static \Illuminate\Database\Query\Builder|\App\Models\Link onlyTrashed() * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Link query() * @method static bool|null restore() * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Link whereCreatedAt($value) * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Link whereDeletedAt($value) * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Link whereId($value) * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Link whereIsDisplay($value) * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Link whereLinkLogo($value) * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Link whereLinkTitle($value) * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Link whereLinkUrl($value) * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Link whereListOrder($value) * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Link whereNote($value) * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Link whereSubsiteId($value) * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Link whereTypeId($value) * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Link whereUpdatedAt($value) * @method static \Illuminate\Database\Query\Builder|\App\Models\Link withTrashed() * @method static \Illuminate\Database\Query\Builder|\App\Models\Link withoutTrashed() * @mixin \Eloquent */ class Link extends Model { use SoftDeletes; protected $table = 'links'; protected $appends = array('up_file','logo_url'); public function getUpFileAttribute() { $up_file = ''; if (preg_match('/^http/', $this->attributes['link_logo'])) { $up_file = null; } else { $up_file = $this->attributes['link_logo']; } return $up_file; } public function getLogoUrlAttribute() { $url = null; if (preg_match('/^http/', $this->attributes['link_logo'])) { $url = $this->attributes['link_logo']; } return $url; } public function show_category() { return $this->belongsTo(LinkCategory::class, 'type_id'); } public function subsites() { return $this->hasMany(SubsiteLink::class, 'link_id'); } }