12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- namespace App\Repositories\Models\Base;
- use App\Repositories\Models\Model;
- use Illuminate\Support\Facades\App;
- use Prettus\Repository\Contracts\Transformable;
- use Prettus\Repository\Traits\TransformableTrait;
- /**
- * Class Resource.
- *
- * @package namespace App\Repositories\Models;
- */
- class Resource extends Model implements Transformable
- {
- protected $table = 'base_resources';
- use TransformableTrait;
- /**
- * The attributes that are mass assignable.
- *
- * @var array
- */
- protected $fillable = ['name', 'original_name', 'path', 'disk', 'url', 'size', 'status'];
- protected static function booted()
- {
- $language = 'zh_CN';
- switch (App::getLocale()) {
- case 'zh_CN':
- default:
- $language = 'zh_CN';
- break;
- case 'en':
- $language = 'en';
- break;
- }
- static::creating(function ($model) use ($language) {
- $model->language = $language;
- });
- }
- public function getUrlAttribute()
- {
- return path_to_url($this->attributes['path']);
- }
- }
|