123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace App\Repositories\Models\Base;
- use App\Repositories\Models\Model;
- class Menu extends Model
- {
- /**
- * @var string
- */
- protected $table = 'base_menus';
- protected $guarded = [];
- /**
- * The attributes excluded from the model's JSON form.
- *
- * @var array
- */
- protected $hidden = [];
- protected $casts = [
- 'meta' => 'json'
- ];
- const TYPE_MENU = 1;
- const TYPE_BTN = 2;
- public static function checkNameIsUnique($name, $ignore_id = 0)
- {
- return self::query()->where('name', $name)->where('type', self::TYPE_MENU)->where('id', '<>', $ignore_id)->exists();
- }
- public static function checkBtnPathIsUnique($path, $ignore_id = 0)
- {
- return self::query()->where('path', $path)->where('type', self::TYPE_BTN)->where('id', '<>', $ignore_id)->exists();
- }
- }
|