1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Database\Eloquent\SoftDeletes;
- class Hrtools extends Model
- {
- use SoftDeletes;
- protected $table = 'hrtools';
- protected $appends = array('up_file','url');
- public function getUpFileAttribute()
- {
- $up_file = '';
- if (preg_match('/^admin\/files\//', $this->attributes['file_url'])) {
- $up_file = $this->attributes['file_url'];
- } else {
- $up_file = null;
- }
- return $up_file;
- }
- public function getUrlAttribute()
- {
- $url = null;
- if (!preg_match('/^files\//', $this->attributes['file_url'])) {
- $url = $this->attributes['file_url'];
- }
- return $url;
- }
- public function show_category()
- {
- return $this->belongsTo(HrtoolsCategory::class, 'type_id');
- }
- }
|