1234567891011121314151617181920212223242526272829303132333435 |
- <?php
- namespace App\Repositories\Models\Base;
- use Carbon\Carbon;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Support\Facades\Cache;
- class Permission extends Model
- {
- /**
- * @var string
- */
- protected $table = 'base_permissions';
- protected $guarded = [];
- /**
- * The attributes excluded from the model's JSON form.
- *
- * @var array
- */
- protected $hidden = [];
- public static function byUrlGetDescription($url, $method)
- {
- return Cache::tags('model')->remember('model:permission:byUrlGetDescription:' . $url . ':' . $method, Carbon::now()->addDays(1), function () use ($url, $method) {
- $info = self::query()->where('url', $url)->where('method', $method)->select(['id', 'name', 'nickname', 'module'])->first();
- if ($info) {
- return $info->toArray();
- }
- return false;
- });
- }
- }
|