123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Database\Eloquent\SoftDeletes;
- 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');
- }
- }
|