sed -n '1,220p' app/Models/Theme.php app/Models/ThemeSettings.php app/Models/StoreSettings.php app/Models/TaxSettings.php app/Models/ShippingZone.php app/Models/ShippingRate.php

<?php

namespace App\Models;

use App\Enums\ThemeStatus;
use App\Models\Concerns\BelongsToStore;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;

class Theme extends Model
{
    /** @use HasFactory<\Database\Factories\ThemeFactory> */
    use BelongsToStore, HasFactory;

    /**
     * @var list<string>
     */
    protected $fillable = [
        'store_id',
        'name',
        'version',
        'status',
        'published_at',
    ];

    /**
     * @var array<string, mixed>
     */
    protected $attributes = [
        'status' => 'draft',
    ];

    /**
     * @return BelongsTo<Store, $this>
     */
    public function store(): BelongsTo
    {
        return $this->belongsTo(Store::class);
    }

    /**
     * @return HasMany<ThemeFile, $this>
     */
    public function files(): HasMany
    {
        return $this->hasMany(ThemeFile::class)->orderBy('path');
    }

    /**
     * @return HasOne<ThemeSettings, $this>
     */
    public function settings(): HasOne
    {
        return $this->hasOne(ThemeSettings::class);
    }

    public function isPublished(): bool
    {
        return $this->status === ThemeStatus::Published && $this->published_at !== null;
    }

    /**
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'status' => ThemeStatus::class,
            'published_at' => 'datetime',
        ];
    }
}
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class ThemeSettings extends Model
{
    /** @use HasFactory<\Database\Factories\ThemeSettingsFactory> */
    use HasFactory;

    public $incrementing = false;

    public const CREATED_AT = null;

    protected $primaryKey = 'theme_id';

    /**
     * @var list<string>
     */
    protected $fillable = [
        'theme_id',
        'settings_json',
    ];

    protected static function booted(): void
    {
        static::addGlobalScope('current_store', function (Builder $builder): void {
            if (! app()->bound('current_store')) {
                return;
            }

            $store = app('current_store');

            if (! $store instanceof Store) {
                return;
            }

            $builder->whereHas('theme', function (Builder $query) use ($store): void {
                $query
                    ->withoutGlobalScopes()
                    ->where('store_id', $store->getKey());
            });
        });
    }

    /**
     * @return BelongsTo<Theme, $this>
     */
    public function theme(): BelongsTo
    {
        return $this->belongsTo(Theme::class);
    }

    /**
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'settings_json' => 'array',
        ];
    }
}
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class StoreSettings extends Model
{
    /** @use HasFactory<\Database\Factories\StoreSettingsFactory> */
    use HasFactory;

    public $incrementing = false;

    public const CREATED_AT = null;

    protected $primaryKey = 'store_id';

    /**
     * @var list<string>
     */
    protected $fillable = [
        'store_id',
        'settings_json',
    ];

    /**
     * @return BelongsTo<Store, $this>
     */
    public function store(): BelongsTo
    {
        return $this->belongsTo(Store::class);
    }

    /**
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'settings_json' => 'array',
        ];
    }
}
<?php

namespace App\Models;

use App\Enums\TaxMode;
use App\Models\Concerns\BelongsToStore;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class TaxSettings extends Model
{
    /** @use HasFactory<\Database\Factories\TaxSettingsFactory> */
    use BelongsToStore, HasFactory;

    public $incrementing = false;

    public $timestamps = false;

    protected $primaryKey = 'store_id';

    /**
     * @var list<string>
     */
    protected $fillable = [
        'store_id',
        'mode',
        'provider',
        'prices_include_tax',
        'config_json',
    ];

    /**


Output:
Chunk ID: bfe70c
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 700
Output:
| Navigation                                                        |
+==================================================================+
|                                                                   |
| MENUS                                                             |
| +----------------------------+  +----------------------------+   |
| | Main Menu        [Edit]    |  | Footer Menu       [Edit]   |   |
| +----------------------------+  +----------------------------+   |
|                                                                   |
| MENU EDITOR (shown when a menu is selected)                      |
| +--------------------------------------------------------------+ |
| | Main Menu                                    [+ Add item]    | |
| |                                                               | |
| | [drag] Home               link: /            [edit] [trash]  | |
| | [drag] Products           collection: All    [edit] [trash]  | |
| | [drag] About Us           page: About        [edit] [trash]  | |
| | [drag] Contact            link: /contact     [edit] [trash]  | |
| |                                                               | |
| |                                            [Save menu]       | |
| +--------------------------------------------------------------+ |
+==================================================================+
```

**Menu list:** Each menu displayed as a card with title and "Edit" button.

**Menu editor (shown when a menu is selected):**
- Menu title as heading
- "Add item" button (ghost, plus icon) in the header
- Sortable list of menu items, each row containing:
  - Drag handle (bars icon)
  - Item label (bold text)
  - Item type and target (small, muted text: e.g., "link: /about" or "collection: Summer Sale")
  - Edit button (pencil icon) and Delete button (trash icon)
- "Save menu" primary button at the bottom

#### Menu Item Form Modal

| Property | Value |
|----------|-------|
| Modal name | `item-form` |
| Max width | md |
| Heading | "Edit menu item" or "Add menu item" (dynamic) |

**Form fields:**
- Label input (placeholder: "About Us")
- Type select: Custom link, Page, Collection, Product (live-bound)
- Conditional fields based on type:
  - **Custom link:** URL input (placeholder: "https://...")
  - **Page/Collection/Product:** Resource select dropdown populated with available resources of that type
- Cancel button (ghost) and "Save item" button (primary)

---

## 15. Apps Page

**Route:** `GET /admin/apps`

**Livewire component:** `App\Livewire\Admin\Apps\Index`

**Blade view:** `resources/views/livewire/admin/apps/index.blade.php`

### Component Requirements

| Property | Type | Purpose |
|----------|------|---------|
| `installedApps` | `Collection` | Apps installed for this store |


sed -n '1,220p' app/Policies/PagePolicy.php app/Policies/ThemePolicy.php app/Models/Page.php app/Models/NavigationMenu.php app/Models/NavigationItem.php

PagePolicy.php

<?php

namespace App\Policies;

use App\Models\User;
use App\Traits\ChecksStoreRole;

class PagePolicy
{
    use ChecksStoreRole;

    public function viewAny(User $user): bool
    {
        return $this->isOwnerAdminOrStaff($user);
    }

    public function view(User $user, object $page): bool
    {
        return $this->isOwnerAdminOrStaff($user, $this->storeIdForModel($page));
    }

    public function create(User $user): bool
    {
        return $this->isOwnerAdminOrStaff($user);
    }

    public function update(User $user, object $page): bool
    {
        return $this->isOwnerAdminOrStaff($user, $this->storeIdForModel($page));
    }

    public function delete(User $user, object $page): bool
    {
        return $this->isOwnerOrAdmin($user, $this->storeIdForModel($page));
    }
}
<?php

namespace App\Policies;

use App\Models\User;
use App\Traits\ChecksStoreRole;

class ThemePolicy
{
    use ChecksStoreRole;

    public function viewAny(User $user): bool
    {
        return $this->isOwnerOrAdmin($user);
    }

    public function view(User $user, object $theme): bool
    {
        return $this->isOwnerOrAdmin($user, $this->storeIdForModel($theme));
    }

    public function create(User $user): bool
    {
        return $this->isOwnerOrAdmin($user);
    }

    public function update(User $user, object $theme): bool
    {
        return $this->isOwnerOrAdmin($user, $this->storeIdForModel($theme));
    }

    public function publish(User $user, object $theme): bool
    {
        return $this->update($user, $theme);
    }

    public function delete(User $user, object $theme): bool
    {
        return $this->isOwnerOrAdmin($user, $this->storeIdForModel($theme));
    }
}
<?php

namespace App\Models;

use App\Enums\PageStatus;
use App\Models\Concerns\BelongsToStore;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class Page extends Model
{
    /** @use HasFactory<\Database\Factories\PageFactory> */
    use BelongsToStore, HasFactory;

    /**
     * @var list<string>
     */
    protected $fillable = [
        'store_id',
        'title',
        'handle',
        'body_html',
        'status',
        'published_at',
    ];

    /**
     * @var array<string, mixed>
     */
    protected $attributes = [
        'status' => 'draft',
    ];

    /**
     * @return BelongsTo<Store, $this>
     */
    public function store(): BelongsTo
    {
        return $this->belongsTo(Store::class);
    }

    public function isPublished(): bool
    {
        return $this->status === PageStatus::Published && $this->published_at !== null;
    }

    /**
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'status' => PageStatus::class,
            'published_at' => 'datetime',
        ];
    }
}
<?php

namespace App\Models;

use App\Models\Concerns\BelongsToStore;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

class NavigationMenu extends Model
{
    /** @use HasFactory<\Database\Factories\NavigationMenuFactory> */
    use BelongsToStore, HasFactory;

    /**
     * @var list<string>
     */
    protected $fillable = [
        'store_id',
        'handle',
        'title',
    ];

    /**
     * @return BelongsTo<Store, $this>
     */
    public function store(): BelongsTo
    {
        return $this->belongsTo(Store::class);
    }

    /**
     * @return HasMany<NavigationItem, $this>
     */
    public function items(): HasMany
    {
        return $this->hasMany(NavigationItem::class, 'menu_id')->orderBy('position');
    }
}
<?php

namespace App\Models;

use App\Enums\NavigationItemType;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class NavigationItem extends Model
{
    /** @use HasFactory<\Database\Factories\NavigationItemFactory> */
    use HasFactory;

    public $timestamps = false;

    /**
     * @var list<string>
     */
    protected $fillable = [
        'menu_id',
        'type',
        'label',
        'url',
        'resource_id',
        'position',
    ];

    /**
     * @var array<string, mixed>
     */
    protected $attributes = [
        'type' => 'link',
        'position' => 0,
    ];

    protected static function booted(): void
    {
        static::addGlobalScope('current_store', function (Builder $builder): void {
            if (! app()->bound('current_store')) {
                return;
            }

            $store = app('current_store');


Output:
Chunk ID: 80136a
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 1204
Output:
<?php

namespace App\Policies;

use App\Models\User;
use App\Traits\ChecksStoreRole;

class PagePolicy
{
    use ChecksStoreRole;

    public function viewAny(User $user): bool
    {
        return $this->isOwnerAdminOrStaff($user);
    }

    public function view(User $user, object $page): bool
    {
        return $this->isOwnerAdminOrStaff($user, $this->storeIdForModel($page));
    }

    public function create(User $user): bool
    {
        return $this->isOwnerAdminOrStaff($user);
    }

    public function update(User $user, object $page): bool
    {
        return $this->isOwnerAdminOrStaff($user, $this->storeIdForModel($page));
    }

    public function delete(User $user, object $page): bool
    {
        return $this->isOwnerOrAdmin($user, $this->storeIdForModel($page));
    }
}
<?php

namespace App\Policies;

use App\Models\User;
use App\Traits\ChecksStoreRole;

class ThemePolicy
{
    use ChecksStoreRole;

    public function viewAny(User $user): bool
    {
        return $this->isOwnerOrAdmin($user);
    }

    public function view(User $user, object $theme): bool
    {
        return $this->isOwnerOrAdmin($user, $this->storeIdForModel($theme));
    }

    public function create(User $user): bool
    {
        return $this->isOwnerOrAdmin($user);
    }

    public function update(User $user, object $theme): bool
    {
        return $this->isOwnerOrAdmin($user, $this->storeIdForModel($theme));
    }

    public function publish(User $user, object $theme): bool
    {
        return $this->update($user, $theme);
    }

    public function delete(User $user, object $theme): bool
    {
        return $this->isOwnerOrAdmin($user, $this->storeIdForModel($theme));
    }
}
<?php

namespace App\Models;

use App\Enums\PageStatus;
use App\Models\Concerns\BelongsToStore;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class Page extends Model
{
    /** @use HasFactory<\Database\Factories\PageFactory> */
    use BelongsToStore, HasFactory;

    /**
     * @var list<string>
     */
    protected $fillable = [
        'store_id',
        'title',
        'handle',
        'body_html',
        'status',
        'published_at',
    ];

    /**
     * @var array<string, mixed>
     */
    protected $attributes = [
        'status' => 'draft',
    ];

    /**
     * @return BelongsTo<Store, $this>
     */
    public function store(): BelongsTo
    {
        return $this->belongsTo(Store::class);
    }

    public function isPublished(): bool
    {
        return $this->status === PageStatus::Published && $this->published_at !== null;
    }

    /**
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'status' => PageStatus::class,
            'published_at' => 'datetime',
        ];
    }
}
<?php

namespace App\Models;

use App\Models\Concerns\BelongsToStore;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

class NavigationMenu extends Model
{
    /** @use HasFactory<\Database\Factories\NavigationMenuFactory> */
    use BelongsToStore, HasFactory;

    /**
     * @var list<string>
     */
    protected $fillable = [
        'store_id',
        'handle',
        'title',
    ];

    /**
     * @return BelongsTo<Store, $this>
     */
    public function store(): BelongsTo
    {
        return $this->belongsTo(Store::class);
    }

    /**
     * @return HasMany<NavigationItem, $this>
     */
    public function items(): HasMany
    {
        return $this->hasMany(NavigationItem::class, 'menu_id')->orderBy('position');
    }
}
<?php

namespace App\Models;

use App\Enums\NavigationItemType;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class NavigationItem extends Model
{
    /** @use HasFactory<\Database\Factories\NavigationItemFactory> */
    use HasFactory;

    public $timestamps = false;

    /**
     * @var list<string>
     */
    protected $fillable = [
        'menu_id',
        'type',
        'label',
        'url',
        'resource_id',
        'position',
    ];

    /**
     * @var array<string, mixed>
     */
    protected $attributes = [
        'type' => 'link',
        'position' => 0,
    ];

    protected static function booted(): void
    {
        static::addGlobalScope('current_store', function (Builder $builder): void {
            if (! app()->bound('current_store')) {
                return;
            }

            $store = app('current_store');


Output:
Chunk ID: 1b86b4
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 1171
Output:
<?php

namespace App\Models;

use App\Enums\ThemeStatus;
use App\Models\Concerns\BelongsToStore;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;

class Theme extends Model
{
    /** @use HasFactory<\Database\Factories\ThemeFactory> */
    use BelongsToStore, HasFactory;

    /**
     * @var list<string>
     */
    protected $fillable = [
        'store_id',
        'name',
        'version',
        'status',
        'published_at',
    ];

    /**
     * @var array<string, mixed>
     */
    protected $attributes = [
        'status' => 'draft',
    ];

    /**
     * @return BelongsTo<Store, $this>
     */
    public function store(): BelongsTo
    {
        return $this->belongsTo(Store::class);
    }

    /**
     * @return HasMany<ThemeFile, $this>
     */
    public function files(): HasMany
    {
        return $this->hasMany(ThemeFile::class)->orderBy('path');
    }

    /**
     * @return HasOne<ThemeSettings, $this>
     */
    public function settings(): HasOne
    {
        return $this->hasOne(ThemeSettings::class);
    }

    public function isPublished(): bool
    {
        return $this->status === ThemeStatus::Published && $this->published_at !== null;
    }

    /**
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'status' => ThemeStatus::class,
            'published_at' => 'datetime',
        ];
    }
}
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class ThemeSettings extends Model
{
    /** @use HasFactory<\Database\Factories\ThemeSettingsFactory> */
    use HasFactory;

    public $incrementing = false;

    public const CREATED_AT = null;

    protected $primaryKey = 'theme_id';

    /**
     * @var list<string>
     */
    protected $fillable = [
        'theme_id',
        'settings_json',
    ];

    protected static function booted(): void
    {
        static::addGlobalScope('current_store', function (Builder $builder): void {
            if (! app()->bound('current_store')) {
                return;
            }

            $store = app('current_store');

            if (! $store instanceof Store) {
                return;
            }

            $builder->whereHas('theme', function (Builder $query) use ($store): void {
                $query
                    ->withoutGlobalScopes()
                    ->where('store_id', $store->getKey());
            });
        });
    }

    /**
     * @return BelongsTo<Theme, $this>
     */
    public function theme(): BelongsTo
    {
        return $this->belongsTo(Theme::class);
    }

    /**
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'settings_json' => 'array',
        ];
    }
}
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class StoreSettings extends Model
{
    /** @use HasFactory<\Database\Factories\StoreSettingsFactory> */
    use HasFactory;

    public $incrementing = false;

    public const CREATED_AT = null;

    protected $primaryKey = 'store_id';

    /**
     * @var list<string>
     */
    protected $fillable = [
        'store_id',
        'settings_json',
    ];

    /**
     * @return BelongsTo<Store, $this>
     */
    public function store(): BelongsTo
    {
        return $this->belongsTo(Store::class);
    }

    /**
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'settings_json' => 'array',
        ];
    }
}
<?php

namespace App\Models;

use App\Enums\TaxMode;
use App\Models\Concerns\BelongsToStore;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class TaxSettings extends Model
{
    /** @use HasFactory<\Database\Factories\TaxSettingsFactory> */
    use BelongsToStore, HasFactory;

    public $incrementing = false;

    public $timestamps = false;

    protected $primaryKey = 'store_id';

    /**
     * @var list<string>
     */
    protected $fillable = [
        'store_id',
        'mode',
        'provider',
        'prices_include_tax',
        'config_json',
    ];

    /**


sed -n '220,520p' app/Models/NavigationItem.php app/Models/TaxSettings.php app/Models/ShippingZone.php app/Models/ShippingRate.php


rg --files app/Enums | xargs -n1 basename


sed -n '1,220p' app/Traits/ChecksStoreRole.php app/Providers/AuthServiceProvider.php bootstrap/app.php


sed -n '220,520p' app/Models/NavigationItem.php app/Models/TaxSettings.php app/Models/ShippingZone.php app/Models/ShippingRate.php

    /**
     * @var list<string>
     */
    protected $fillable = [
        'zone_id',
        'name',
        'type',
        'config_json',
        'is_active',
    ];

    /**
     * @var array<string, mixed>
     */
    protected $attributes = [
        'type' => 'flat',
        'config_json' => '{}',
        'is_active' => true,
    ];

    protected static function booted(): void
    {
        static::addGlobalScope('current_store', function (Builder $builder): void {
            if (! app()->bound('current_store')) {
                return;
            }

            $store = app('current_store');

            if (! $store instanceof Store) {
                return;
            }

            $builder->whereHas('zone', function (Builder $query) use ($store): void {
                $query
                    ->withoutGlobalScopes()
                    ->where('store_id', $store->getKey());
            });
        });
    }

    /**
     * @return BelongsTo<ShippingZone, $this>
     */
    public function zone(): BelongsTo
    {
        return $this->belongsTo(ShippingZone::class, 'zone_id');
    }

    /**
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'type' => ShippingRateType::class,
            'config_json' => 'array',
            'is_active' => 'bool',
        ];
    }
}


Output:
Chunk ID: f2de99
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 344
Output:
    /**
     * @var list<string>
     */
    protected $fillable = [
        'zone_id',
        'name',
        'type',
        'config_json',
        'is_active',
    ];

    /**
     * @var array<string, mixed>
     */
    protected $attributes = [
        'type' => 'flat',
        'config_json' => '{}',
        'is_active' => true,
    ];

    protected static function booted(): void
    {
        static::addGlobalScope('current_store', function (Builder $builder): void {
            if (! app()->bound('current_store')) {
                return;
            }

            $store = app('current_store');

            if (! $store instanceof Store) {
                return;
            }

            $builder->whereHas('zone', function (Builder $query) use ($store): void {
                $query
                    ->withoutGlobalScopes()
                    ->where('store_id', $store->getKey());
            });
        });
    }

    /**
     * @return BelongsTo<ShippingZone, $this>
     */
    public function zone(): BelongsTo
    {
        return $this->belongsTo(ShippingZone::class, 'zone_id');
    }

    /**
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'type' => ShippingRateType::class,
            'config_json' => 'array',
            'is_active' => 'bool',
        ];
    }
}


sed -n '1,220p' app/Traits/ChecksStoreRole.php app/Providers/AuthServiceProvider.php bootstrap/app.php

sed: app/Providers/AuthServiceProvider.php: No such file or directory
<?php

namespace App\Traits;

use App\Enums\StoreUserRole;
use App\Models\Store;
use App\Models\User;

trait ChecksStoreRole
{
    public function getStoreRole(User $user, ?int $storeId = null): ?StoreUserRole
    {
        $storeId ??= $this->currentStoreId();

        if (! $storeId) {
            return null;
        }

        return $user->roleForStoreId($storeId);
    }

    /**
     * @param  array<int, StoreUserRole>  $roles
     */
    public function hasRole(User $user, ?int $storeId, array $roles): bool
    {
        $role = $this->getStoreRole($user, $storeId);

        return $role !== null && in_array($role, $roles, true);
    }

    public function isOwnerOnly(User $user, ?int $storeId = null): bool
    {
        return $this->hasRole($user, $storeId, [StoreUserRole::Owner]);
    }

    public function isOwnerOrAdmin(User $user, ?int $storeId = null): bool
    {
        return $this->hasRole($user, $storeId, [StoreUserRole::Owner, StoreUserRole::Admin]);
    }

    public function isOwnerAdminOrStaff(User $user, ?int $storeId = null): bool
    {
        return $this->hasRole($user, $storeId, [StoreUserRole::Owner, StoreUserRole::Admin, StoreUserRole::Staff]);
    }

    public function isAnyRole(User $user, ?int $storeId = null): bool
    {
        return $this->getStoreRole($user, $storeId) !== null;
    }

    protected function currentStoreId(): ?int
    {
        if (! app()->bound('current_store')) {
            return null;
        }

        $store = app('current_store');

        return $store instanceof Store ? $store->getKey() : null;
    }

    protected function storeIdForModel(object $model): ?int
    {
        if (method_exists($model, 'getAttribute')) {
            $storeId = $model->getAttribute('store_id');

            return is_numeric($storeId) ? (int) $storeId : null;
        }

        if (property_exists($model, 'store_id')) {
            return is_numeric($model->store_id) ? (int) $model->store_id : null;
        }

        return null;
    }
}
<?php

use App\Http\Middleware\CheckStoreRole;
use App\Http\Middleware\ResolveStore;
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;

return Application::configure(basePath: dirname(__DIR__))
    ->withRouting(
        web: __DIR__.'/../routes/web.php',
        api: __DIR__.'/../routes/api.php',
        commands: __DIR__.'/../routes/console.php',
        health: '/up',
    )
    ->withMiddleware(function (Middleware $middleware): void {
        $middleware->alias([
            'role.check' => CheckStoreRole::class,
            'store.resolve' => ResolveStore::class,
        ]);

        $middleware->appendToGroup('storefront', [
            ResolveStore::class,
        ]);

        $middleware->appendToGroup('admin', [
            ResolveStore::class,
            CheckStoreRole::class,
        ]);
    })
    ->withExceptions(function (Exceptions $exceptions): void {
        //
    })->create();


rg --files app/Enums | xargs -n1 basename

PaymentStatus.php
ThemeStatus.php
StoreStatus.php
FulfillmentStatus.php
ProductStatus.php
StoreDomainType.php
CheckoutStatus.php
FinancialStatus.php
ShippingRateType.php
MediaStatus.php
CollectionStatus.php
DiscountValueType.php
DiscountStatus.php
NavigationItemType.php
VariantStatus.php
DiscountType.php
PageStatus.php
OrderStatus.php
MediaType.php
FulfillmentShipmentStatus.php
TaxMode.php
CollectionType.php
CartStatus.php
RefundStatus.php
InventoryPolicy.php
StoreUserRole.php
PaymentMethod.php


Output:
Chunk ID: fb1ffa
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 125
Output:
PaymentStatus.php
ThemeStatus.php
StoreStatus.php
FulfillmentStatus.php
ProductStatus.php
StoreDomainType.php
CheckoutStatus.php
FinancialStatus.php
ShippingRateType.php
MediaStatus.php
CollectionStatus.php
DiscountValueType.php
DiscountStatus.php
NavigationItemType.php
VariantStatus.php
DiscountType.php
PageStatus.php
OrderStatus.php
MediaType.php
FulfillmentShipmentStatus.php
TaxMode.php
CollectionType.php
CartStatus.php
RefundStatus.php
InventoryPolicy.php
StoreUserRole.php
PaymentMethod.php


Output:
Chunk ID: 56e151
Wall time: 0.0000 seconds
Process exited with code 1
Original token count: 773
Output:
sed: app/Providers/AuthServiceProvider.php: No such file or directory
<?php

namespace App\Traits;

use App\Enums\StoreUserRole;
use App\Models\Store;
use App\Models\User;

trait ChecksStoreRole
{
    public function getStoreRole(User $user, ?int $storeId = null): ?StoreUserRole
    {
        $storeId ??= $this->currentStoreId();

        if (! $storeId) {
            return null;
        }

        return $user->roleForStoreId($storeId);
    }

    /**
     * @param  array<int, StoreUserRole>  $roles
     */
    public function hasRole(User $user, ?int $storeId, array $roles): bool
    {
        $role = $this->getStoreRole($user, $storeId);

        return $role !== null && in_array($role, $roles, true);
    }

    public function isOwnerOnly(User $user, ?int $storeId = null): bool
    {
        return $this->hasRole($user, $storeId, [StoreUserRole::Owner]);
    }

    public function isOwnerOrAdmin(User $user, ?int $storeId = null): bool
    {
        return $this->hasRole($user, $storeId, [StoreUserRole::Owner, StoreUserRole::Admin]);
    }

    public function isOwnerAdminOrStaff(User $user, ?int $storeId = null): bool
    {
        return $this->hasRole($user, $storeId, [StoreUserRole::Owner, StoreUserRole::Admin, StoreUserRole::Staff]);
    }

    public function isAnyRole(User $user, ?int $storeId = null): bool
    {
        return $this->getStoreRole($user, $storeId) !== null;
    }

    protected function currentStoreId(): ?int
    {
        if (! app()->bound('current_store')) {
            return null;
        }

        $store = app('current_store');

        return $store instanceof Store ? $store->getKey() : null;
    }

    protected function storeIdForModel(object $model): ?int
    {
        if (method_exists($model, 'getAttribute')) {
            $storeId = $model->getAttribute('store_id');

            return is_numeric($storeId) ? (int) $storeId : null;
        }

        if (property_exists($model, 'store_id')) {
            return is_numeric($model->store_id) ? (int) $model->store_id : null;
        }

        return null;
    }
}
<?php

use App\Http\Middleware\CheckStoreRole;
use App\Http\Middleware\ResolveStore;
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;

return Application::configure(basePath: dirname(__DIR__))
    ->withRouting(
        web: __DIR__.'/../routes/web.php',
        api: __DIR__.'/../routes/api.php',
        commands: __DIR__.'/../routes/console.php',
        health: '/up',
    )
    ->withMiddleware(function (Middleware $middleware): void {
        $middleware->alias([
            'role.check' => CheckStoreRole::class,
            'store.resolve' => ResolveStore::class,
        ]);

        $middleware->appendToGroup('storefront', [
            ResolveStore::class,
        ]);

        $middleware->appendToGroup('admin', [
            ResolveStore::class,
            CheckStoreRole::class,
        ]);
    })
    ->withExceptions(function (Exceptions $exceptions): void {
        //
    })->create();


sed -n '1,220p' app/Models/NavigationItem.php


sed -n '1,220p' app/Models/TaxSettings.php


sed -n '1,220p' app/Models/ShippingZone.php


sed -n '1,220p' app/Models/ShippingRate.php


sed -n '1,220p' app/Models/TaxSettings.php

<?php

namespace App\Models;

use App\Enums\TaxMode;
use App\Models\Concerns\BelongsToStore;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class TaxSettings extends Model
{
    /** @use HasFactory<\Database\Factories\TaxSettingsFactory> */
    use BelongsToStore, HasFactory;

    public $incrementing = false;

    public $timestamps = false;

    protected $primaryKey = 'store_id';

    /**
     * @var list<string>
     */
    protected $fillable = [
        'store_id',
        'mode',
        'provider',
        'prices_include_tax',
        'config_json',
    ];

    /**
     * @var array<string, mixed>
     */
    protected $attributes = [
        'mode' => 'manual',
        'provider' => 'none',
        'prices_include_tax' => false,
        'config_json' => '{}',
    ];

    /**
     * @return BelongsTo<Store, $this>
     */
    public function store(): BelongsTo
    {
        return $this->belongsTo(Store::class);
    }

    /**
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'mode' => TaxMode::class,
            'prices_include_tax' => 'bool',
            'config_json' => 'array',
        ];
    }
}


sed -n '1,220p' app/Models/NavigationItem.php

<?php

namespace App\Models;

use App\Enums\NavigationItemType;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class NavigationItem extends Model
{
    /** @use HasFactory<\Database\Factories\NavigationItemFactory> */
    use HasFactory;

    public $timestamps = false;

    /**
     * @var list<string>
     */
    protected $fillable = [
        'menu_id',
        'type',
        'label',
        'url',
        'resource_id',
        'position',
    ];

    /**
     * @var array<string, mixed>
     */
    protected $attributes = [
        'type' => 'link',
        'position' => 0,
    ];

    protected static function booted(): void
    {
        static::addGlobalScope('current_store', function (Builder $builder): void {
            if (! app()->bound('current_store')) {
                return;
            }

            $store = app('current_store');

            if (! $store instanceof Store) {
                return;
            }

            $builder->whereHas('menu', function (Builder $query) use ($store): void {
                $query
                    ->withoutGlobalScopes()
                    ->where('store_id', $store->getKey());
            });
        });
    }

    /**
     * @return BelongsTo<NavigationMenu, $this>
     */
    public function menu(): BelongsTo
    {
        return $this->belongsTo(NavigationMenu::class, 'menu_id');
    }

    /**
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'type' => NavigationItemType::class,
            'resource_id' => 'integer',
            'position' => 'integer',
        ];
    }
}


Output:
Chunk ID: 9e7a6a
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 446
Output:
<?php

namespace App\Models;

use App\Enums\NavigationItemType;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class NavigationItem extends Model
{
    /** @use HasFactory<\Database\Factories\NavigationItemFactory> */
    use HasFactory;

    public $timestamps = false;

    /**
     * @var list<string>
     */
    protected $fillable = [
        'menu_id',
        'type',
        'label',
        'url',
        'resource_id',
        'position',
    ];

    /**
     * @var array<string, mixed>
     */
    protected $attributes = [
        'type' => 'link',
        'position' => 0,
    ];

    protected static function booted(): void
    {
        static::addGlobalScope('current_store', function (Builder $builder): void {
            if (! app()->bound('current_store')) {
                return;
            }

            $store = app('current_store');

            if (! $store instanceof Store) {
                return;
            }

            $builder->whereHas('menu', function (Builder $query) use ($store): void {
                $query
                    ->withoutGlobalScopes()
                    ->where('store_id', $store->getKey());
            });
        });
    }

    /**
     * @return BelongsTo<NavigationMenu, $this>
     */
    public function menu(): BelongsTo
    {
        return $this->belongsTo(NavigationMenu::class, 'menu_id');
    }

    /**
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'type' => NavigationItemType::class,
            'resource_id' => 'integer',
            'position' => 'integer',
        ];
    }
}


Output:
Chunk ID: 4fa8fe
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 325
Output:
<?php

namespace App\Models;

use App\Enums\TaxMode;
use App\Models\Concerns\BelongsToStore;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class TaxSettings extends Model
{
    /** @use HasFactory<\Database\Factories\TaxSettingsFactory> */
    use BelongsToStore, HasFactory;

    public $incrementing = false;

    public $timestamps = false;

    protected $primaryKey = 'store_id';

    /**
     * @var list<string>
     */
    protected $fillable = [
        'store_id',
        'mode',
        'provider',
        'prices_include_tax',
        'config_json',
    ];

    /**
     * @var array<string, mixed>
     */
    protected $attributes = [
        'mode' => 'manual',
        'provider' => 'none',
        'prices_include_tax' => false,
        'config_json' => '{}',
    ];

    /**
     * @return BelongsTo<Store, $this>
     */
    public function store(): BelongsTo
    {
        return $this->belongsTo(Store::class);
    }

    /**
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'mode' => TaxMode::class,
            'prices_include_tax' => 'bool',
            'config_json' => 'array',
        ];
    }
}


sed -n '1,220p' app/Models/ShippingZone.php

<?php

namespace App\Models;

use App\Models\Concerns\BelongsToStore;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

class ShippingZone extends Model
{
    /** @use HasFactory<\Database\Factories\ShippingZoneFactory> */
    use BelongsToStore, HasFactory;

    public $timestamps = false;

    /**
     * @var list<string>
     */
    protected $fillable = [
        'store_id',
        'name',
        'countries_json',
        'regions_json',
    ];

    /**
     * @var array<string, mixed>
     */
    protected $attributes = [
        'countries_json' => '[]',
        'regions_json' => '[]',
    ];

    /**
     * @return BelongsTo<Store, $this>
     */
    public function store(): BelongsTo
    {
        return $this->belongsTo(Store::class);
    }

    /**
     * @return HasMany<ShippingRate, $this>
     */
    public function rates(): HasMany
    {
        return $this->hasMany(ShippingRate::class, 'zone_id');
    }

    /**
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'countries_json' => 'array',
            'regions_json' => 'array',
        ];
    }
}


Output:
Chunk ID: e847f3
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 326
Output:
<?php

namespace App\Models;

use App\Models\Concerns\BelongsToStore;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

class ShippingZone extends Model
{
    /** @use HasFactory<\Database\Factories\ShippingZoneFactory> */
    use BelongsToStore, HasFactory;

    public $timestamps = false;

    /**
     * @var list<string>
     */
    protected $fillable = [
        'store_id',
        'name',
        'countries_json',
        'regions_json',
    ];

    /**
     * @var array<string, mixed>
     */
    protected $attributes = [
        'countries_json' => '[]',
        'regions_json' => '[]',
    ];

    /**
     * @return BelongsTo<Store, $this>
     */
    public function store(): BelongsTo
    {
        return $this->belongsTo(Store::class);
    }

    /**
     * @return HasMany<ShippingRate, $this>
     */
    public function rates(): HasMany
    {
        return $this->hasMany(ShippingRate::class, 'zone_id');
    }

    /**
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'countries_json' => 'array',
            'regions_json' => 'array',
        ];
    }
}


sed -n '1,220p' app/Models/ShippingRate.php

<?php

namespace App\Models;

use App\Enums\ShippingRateType;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class ShippingRate extends Model
{
    /** @use HasFactory<\Database\Factories\ShippingRateFactory> */
    use HasFactory;

    public $timestamps = false;

    /**
     * @var list<string>
     */
    protected $fillable = [
        'zone_id',
        'name',
        'type',
        'config_json',
        'is_active',
    ];

    /**
     * @var array<string, mixed>
     */
    protected $attributes = [
        'type' => 'flat',
        'config_json' => '{}',
        'is_active' => true,
    ];

    protected static function booted(): void
    {
        static::addGlobalScope('current_store', function (Builder $builder): void {
            if (! app()->bound('current_store')) {
                return;
            }

            $store = app('current_store');

            if (! $store instanceof Store) {
                return;
            }

            $builder->whereHas('zone', function (Builder $query) use ($store): void {
                $query
                    ->withoutGlobalScopes()
                    ->where('store_id', $store->getKey());
            });
        });
    }

    /**
     * @return BelongsTo<ShippingZone, $this>
     */
    public function zone(): BelongsTo
    {
        return $this->belongsTo(ShippingZone::class, 'zone_id');
    }

    /**
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'type' => ShippingRateType::class,
            'config_json' => 'array',
            'is_active' => 'bool',
        ];
    }
}


Output:
Chunk ID: faedb0
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 447
Output:
<?php

namespace App\Models;

use App\Enums\ShippingRateType;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class ShippingRate extends Model
{
    /** @use HasFactory<\Database\Factories\ShippingRateFactory> */
    use HasFactory;

    public $timestamps = false;

    /**
     * @var list<string>
     */
    protected $fillable = [
        'zone_id',
        'name',
        'type',
        'config_json',
        'is_active',
    ];

    /**
     * @var array<string, mixed>
     */
    protected $attributes = [
        'type' => 'flat',
        'config_json' => '{}',
        'is_active' => true,
    ];

    protected static function booted(): void
    {
        static::addGlobalScope('current_store', function (Builder $builder): void {
            if (! app()->bound('current_store')) {
                return;
            }

            $store = app('current_store');

            if (! $store instanceof Store) {
                return;
            }

            $builder->whereHas('zone', function (Builder $query) use ($store): void {
                $query
                    ->withoutGlobalScopes()
                    ->where('store_id', $store->getKey());
            });
        });
    }

    /**
     * @return BelongsTo<ShippingZone, $this>
     */
    public function zone(): BelongsTo
    {
        return $this->belongsTo(ShippingZone::class, 'zone_id');
    }

    /**
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'type' => ShippingRateType::class,
            'config_json' => 'array',
            'is_active' => 'bool',
        ];
    }
}


rg -n "Policy|Gate|can\(" app/Policies app/Providers app/Livewire/Admin tests/Feature/Admin | head -200


rg -n "StoreDomain|StoreSettings|TaxSettings|ShippingZone|NavigationMenu" app/Policies app/Models app/Traits tests/Feature


sed -n '1,140p' app/Policies/ProductPolicy.php app/Policies/CollectionPolicy.php app/Policies/DiscountPolicy.php app/Policies/OrderPolicy.php


rg -n "Policy|Gate|can\(" app/Policies app/Providers app/Livewire/Admin tests/Feature/Admin | head -200

rg -n "Policy|Gate|can\\(" app/Policies app/Providers app/Livewire/Admin tests/Feature/Admin

Question: Policy|Gate|can\(

app/Policies/OrderPolicy.php:8:class OrderPolicy
app/Policies/StorePolicy.php:9:class StorePolicy
app/Policies/RefundPolicy.php:8:class RefundPolicy
app/Policies/ThemePolicy.php:8:class ThemePolicy
app/Policies/FulfillmentPolicy.php:8:class FulfillmentPolicy
app/Policies/CollectionPolicy.php:8:class CollectionPolicy
app/Policies/PagePolicy.php:8:class PagePolicy
app/Policies/DiscountPolicy.php:8:class DiscountPolicy
app/Policies/CustomerPolicy.php:8:class CustomerPolicy
app/Policies/ProductPolicy.php:8:class ProductPolicy


Output:
Chunk ID: 1e79ec
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 132
Output:
app/Policies/OrderPolicy.php:8:class OrderPolicy
app/Policies/StorePolicy.php:9:class StorePolicy
app/Policies/RefundPolicy.php:8:class RefundPolicy
app/Policies/ThemePolicy.php:8:class ThemePolicy
app/Policies/FulfillmentPolicy.php:8:class FulfillmentPolicy
app/Policies/CollectionPolicy.php:8:class CollectionPolicy
app/Policies/PagePolicy.php:8:class PagePolicy
app/Policies/DiscountPolicy.php:8:class DiscountPolicy
app/Policies/CustomerPolicy.php:8:class CustomerPolicy
app/Policies/ProductPolicy.php:8:class ProductPolicy


sed -n '1,140p' app/Policies/ProductPolicy.php app/Policies/CollectionPolicy.php app/Policies/DiscountPolicy.php app/Policies/OrderPolicy.php

<?php

namespace App\Policies;

use App\Models\User;
use App\Traits\ChecksStoreRole;

class ProductPolicy
{
    use ChecksStoreRole;

    public function viewAny(User $user): bool
    {
        return $this->isAnyRole($user);
    }

    public function view(User $user, object $product): bool
    {
        return $this->isAnyRole($user, $this->storeIdForModel($product));
    }

    public function create(User $user): bool
    {
        return $this->isOwnerAdminOrStaff($user);
    }

    public function update(User $user, object $product): bool
    {
        return $this->isOwnerAdminOrStaff($user, $this->storeIdForModel($product));
    }

    public function delete(User $user, object $product): bool
    {
        return $this->isOwnerOrAdmin($user, $this->storeIdForModel($product));
    }

    public function archive(User $user, object $product): bool
    {
        return $this->delete($user, $product);
    }

    public function restore(User $user, object $product): bool
    {
        return $this->delete($user, $product);
    }
}
<?php

namespace App\Policies;

use App\Models\User;
use App\Traits\ChecksStoreRole;

class CollectionPolicy
{
    use ChecksStoreRole;

    public function viewAny(User $user): bool
    {
        return $this->isAnyRole($user);
    }

    public function view(User $user, object $collection): bool
    {
        return $this->isAnyRole($user, $this->storeIdForModel($collection));
    }

    public function create(User $user): bool
    {
        return $this->isOwnerAdminOrStaff($user);
    }

    public function update(User $user, object $collection): bool
    {
        return $this->isOwnerAdminOrStaff($user, $this->storeIdForModel($collection));
    }

    public function delete(User $user, object $collection): bool
    {
        return $this->isOwnerOrAdmin($user, $this->storeIdForModel($collection));
    }
}
<?php

namespace App\Policies;

use App\Models\User;
use App\Traits\ChecksStoreRole;

class DiscountPolicy
{
    use ChecksStoreRole;

    public function viewAny(User $user): bool
    {
        return $this->isAnyRole($user);
    }

    public function view(User $user, object $discount): bool
    {
        return $this->isAnyRole($user, $this->storeIdForModel($discount));
    }

    public function create(User $user): bool
    {
        return $this->isOwnerAdminOrStaff($user);
    }

    public function update(User $user, object $discount): bool
    {
        return $this->isOwnerAdminOrStaff($user, $this->storeIdForModel($discount));
    }

    public function delete(User $user, object $discount): bool
    {
        return $this->isOwnerOrAdmin($user, $this->storeIdForModel($discount));
    }
}
<?php

namespace App\Policies;

use App\Models\User;
use App\Traits\ChecksStoreRole;

class OrderPolicy
{
    use ChecksStoreRole;

    public function viewAny(User $user): bool
    {
        return $this->isAnyRole($user);
    }

    public function view(User $user, object $order): bool
    {
        return $this->isAnyRole($user, $this->storeIdForModel($order));
    }

    public function update(User $user, object $order): bool


rg -n "StoreDomain|StoreSettings|TaxSettings|ShippingZone|NavigationMenu" app/Policies app/Models app/Traits tests/Feature

rg -n 'StoreDomain|StoreSettings|TaxSettings|ShippingZone|NavigationMenu' app/Policies app/Models app/Traits tests/Feature

Question: StoreDomain|StoreSettings|TaxSettings|ShippingZone|NavigationMenu

app/Models/StoreDomain.php:5:use App\Enums\StoreDomainType;
app/Models/StoreDomain.php:10:class StoreDomain extends Model
app/Models/StoreDomain.php:12:    /** @use HasFactory<\Database\Factories\StoreDomainFactory> */
app/Models/StoreDomain.php:42:            'type' => StoreDomainType::class,
tests/Feature/Orders/OrderServiceTest.php:19:use App\Models\ShippingZone;
tests/Feature/Orders/OrderServiceTest.php:21:use App\Models\StoreSettings;
tests/Feature/Orders/OrderServiceTest.php:22:use App\Models\TaxSettings;
tests/Feature/Orders/OrderServiceTest.php:36:    StoreSettings::query()->create([
tests/Feature/Orders/OrderServiceTest.php:44:    TaxSettings::withoutGlobalScopes()->create([
tests/Feature/Orders/OrderServiceTest.php:76:    $zone = ShippingZone::withoutGlobalScopes()
tests/Feature/Orders/OrderServiceTest.php:81:    if (! $zone instanceof ShippingZone) {
tests/Feature/Orders/OrderServiceTest.php:82:        $zone = ShippingZone::withoutGlobalScopes()->create([
app/Models/Store.php:40:     * @return HasMany<StoreDomain, $this>
app/Models/Store.php:44:        return $this->hasMany(StoreDomain::class);
app/Models/Store.php:58:     * @return HasOne<StoreSettings, $this>
app/Models/Store.php:62:        return $this->hasOne(StoreSettings::class);
app/Models/Store.php:82:     * @return HasMany<NavigationMenu, $this>
app/Models/Store.php:86:        return $this->hasMany(NavigationMenu::class);
app/Models/Store.php:106:     * @return HasMany<ShippingZone, $this>
app/Models/Store.php:110:        return $this->hasMany(ShippingZone::class);
app/Models/Store.php:114:     * @return HasOne<TaxSettings, $this>
app/Models/Store.php:118:        return $this->hasOne(TaxSettings::class);
tests/Feature/Orders/BankTransferOrderTest.php:19:use App\Models\StoreSettings;
tests/Feature/Orders/BankTransferOrderTest.php:34:    StoreSettings::query()->create([
app/Models/StoreSettings.php:9:class StoreSettings extends Model
app/Models/StoreSettings.php:11:    /** @use HasFactory<\Database\Factories\StoreSettingsFactory> */
app/Models/ShippingRate.php:60:     * @return BelongsTo<ShippingZone, $this>
app/Models/ShippingRate.php:64:        return $this->belongsTo(ShippingZone::class, 'zone_id');
app/Models/NavigationMenu.php:11:class NavigationMenu extends Model
app/Models/NavigationMenu.php:13:    /** @use HasFactory<\Database\Factories\NavigationMenuFactory> */
tests/Feature/Checkout/PricingServicesTest.php:11:use App\Models\ShippingZone;
tests/Feature/Checkout/PricingServicesTest.php:13:use App\Models\TaxSettings;
tests/Feature/Checkout/PricingServicesTest.php:27:    TaxSettings::withoutGlobalScopes()->create([
tests/Feature/Checkout/PricingServicesTest.php:89:    $zone = ShippingZone::withoutGlobalScopes()->create([
tests/Feature/Checkout/PricingServicesTest.php:117:    $zone = ShippingZone::withoutGlobalScopes()->create([
tests/Feature/Checkout/PricingServicesTest.php:208:    $zone = ShippingZone::withoutGlobalScopes()->create([
app/Models/ShippingZone.php:11:class ShippingZone extends Model
app/Models/ShippingZone.php:13:    /** @use HasFactory<\Database\Factories\ShippingZoneFactory> */
tests/Feature/Checkout/CheckoutServiceTest.php:12:use App\Models\ShippingZone;
tests/Feature/Checkout/CheckoutServiceTest.php:14:use App\Models\TaxSettings;
tests/Feature/Checkout/CheckoutServiceTest.php:26:    TaxSettings::withoutGlobalScopes()->create([
tests/Feature/Checkout/CheckoutServiceTest.php:78:    $zone = ShippingZone::withoutGlobalScopes()->create([
tests/Feature/Checkout/CheckoutServiceTest.php:119:    ShippingZone::withoutGlobalScopes()->create([
tests/Feature/Checkout/CheckoutServiceTest.php:151:    $zone = ShippingZone::withoutGlobalScopes()->create([
tests/Feature/Checkout/CheckoutServiceTest.php:181:    $zone = ShippingZone::withoutGlobalScopes()->create([
app/Models/TaxSettings.php:11:class TaxSettings extends Model
app/Models/TaxSettings.php:13:    /** @use HasFactory<\Database\Factories\TaxSettingsFactory> */
app/Models/NavigationItem.php:60:     * @return BelongsTo<NavigationMenu, $this>
app/Models/NavigationItem.php:64:        return $this->belongsTo(NavigationMenu::class, 'menu_id');
tests/Feature/Foundation/TenancyTest.php:5:use App\Models\StoreDomain;
tests/Feature/Foundation/TenancyTest.php:22:        ->and(StoreDomain::query()->where('hostname', 'shop.test')->exists())->toBeTrue()
tests/Feature/Foundation/TenancyTest.php:40:    StoreDomain::factory()->create([
tests/Feature/Storefront/ThemeDataTest.php:5:use App\Models\NavigationMenu;
tests/Feature/Storefront/ThemeDataTest.php:37:        ->and(NavigationMenu::withoutGlobalScopes()->count())->toBe(4)
tests/Feature/Storefront/ThemeDataTest.php:49:    NavigationMenu::factory()->create(['store_id' => $firstStore->getKey(), 'handle' => 'first-menu']);
tests/Feature/Storefront/ThemeDataTest.php:50:    NavigationMenu::factory()->create(['store_id' => $secondStore->getKey(), 'handle' => 'second-menu']);
tests/Feature/Storefront/ThemeDataTest.php:56:        ->and(NavigationMenu::query()->pluck('handle')->all())->toBe(['first-menu']);
tests/Feature/Storefront/ThemeDataTest.php:64:    $firstMenu = NavigationMenu::factory()->create(['store_id' => $firstStore->getKey()]);
tests/Feature/Storefront/ThemeDataTest.php:65:    $secondMenu = NavigationMenu::factory()->create(['store_id' => $secondStore->getKey()]);
tests/Feature/Storefront/ThemeDataTest.php:96:    $menu = NavigationMenu::withoutGlobalScopes()


Output:
Chunk ID: 32bdca
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 1359
Output:
app/Models/StoreDomain.php:5:use App\Enums\StoreDomainType;
app/Models/StoreDomain.php:10:class StoreDomain extends Model
app/Models/StoreDomain.php:12:    /** @use HasFactory<\Database\Factories\StoreDomainFactory> */
app/Models/StoreDomain.php:42:            'type' => StoreDomainType::class,
tests/Feature/Orders/OrderServiceTest.php:19:use App\Models\ShippingZone;
tests/Feature/Orders/OrderServiceTest.php:21:use App\Models\StoreSettings;
tests/Feature/Orders/OrderServiceTest.php:22:use App\Models\TaxSettings;
tests/Feature/Orders/OrderServiceTest.php:36:    StoreSettings::query()->create([
tests/Feature/Orders/OrderServiceTest.php:44:    TaxSettings::withoutGlobalScopes()->create([
tests/Feature/Orders/OrderServiceTest.php:76:    $zone = ShippingZone::withoutGlobalScopes()
tests/Feature/Orders/OrderServiceTest.php:81:    if (! $zone instanceof ShippingZone) {
tests/Feature/Orders/OrderServiceTest.php:82:        $zone = ShippingZone::withoutGlobalScopes()->create([
app/Models/Store.php:40:     * @return HasMany<StoreDomain, $this>
app/Models/Store.php:44:        return $this->hasMany(StoreDomain::class);
app/Models/Store.php:58:     * @return HasOne<StoreSettings, $this>
app/Models/Store.php:62:        return $this->hasOne(StoreSettings::class);
app/Models/Store.php:82:     * @return HasMany<NavigationMenu, $this>
app/Models/Store.php:86:        return $this->hasMany(NavigationMenu::class);
app/Models/Store.php:106:     * @return HasMany<ShippingZone, $this>
app/Models/Store.php:110:        return $this->hasMany(ShippingZone::class);
app/Models/Store.php:114:     * @return HasOne<TaxSettings, $this>
app/Models/Store.php:118:        return $this->hasOne(TaxSettings::class);
tests/Feature/Orders/BankTransferOrderTest.php:19:use App\Models\StoreSettings;
tests/Feature/Orders/BankTransferOrderTest.php:34:    StoreSettings::query()->create([
app/Models/StoreSettings.php:9:class StoreSettings extends Model
app/Models/StoreSettings.php:11:    /** @use HasFactory<\Database\Factories\StoreSettingsFactory> */
app/Models/ShippingRate.php:60:     * @return BelongsTo<ShippingZone, $this>
app/Models/ShippingRate.php:64:        return $this->belongsTo(ShippingZone::class, 'zone_id');
app/Models/NavigationMenu.php:11:class NavigationMenu extends Model
app/Models/NavigationMenu.php:13:    /** @use HasFactory<\Database\Factories\NavigationMenuFactory> */
tests/Feature/Checkout/PricingServicesTest.php:11:use App\Models\ShippingZone;
tests/Feature/Checkout/PricingServicesTest.php:13:use App\Models\TaxSettings;
tests/Feature/Checkout/PricingServicesTest.php:27:    TaxSettings::withoutGlobalScopes()->create([
tests/Feature/Checkout/PricingServicesTest.php:89:    $zone = ShippingZone::withoutGlobalScopes()->create([
tests/Feature/Checkout/PricingServicesTest.php:117:    $zone = ShippingZone::withoutGlobalScopes()->create([
tests/Feature/Checkout/PricingServicesTest.php:208:    $zone = ShippingZone::withoutGlobalScopes()->create([
app/Models/ShippingZone.php:11:class ShippingZone extends Model
app/Models/ShippingZone.php:13:    /** @use HasFactory<\Database\Factories\ShippingZoneFactory> */
tests/Feature/Checkout/CheckoutServiceTest.php:12:use App\Models\ShippingZone;
tests/Feature/Checkout/CheckoutServiceTest.php:14:use App\Models\TaxSettings;
tests/Feature/Checkout/CheckoutServiceTest.php:26:    TaxSettings::withoutGlobalScopes()->create([
tests/Feature/Checkout/CheckoutServiceTest.php:78:    $zone = ShippingZone::withoutGlobalScopes()->create([
tests/Feature/Checkout/CheckoutServiceTest.php:119:    ShippingZone::withoutGlobalScopes()->create([
tests/Feature/Checkout/CheckoutServiceTest.php:151:    $zone = ShippingZone::withoutGlobalScopes()->create([
tests/Feature/Checkout/CheckoutServiceTest.php:181:    $zone = ShippingZone::withoutGlobalScopes()->create([
app/Models/TaxSettings.php:11:class TaxSettings extends Model
app/Models/TaxSettings.php:13:    /** @use HasFactory<\Database\Factories\TaxSettingsFactory> */
app/Models/NavigationItem.php:60:     * @return BelongsTo<NavigationMenu, $this>
app/Models/NavigationItem.php:64:        return $this->belongsTo(NavigationMenu::class, 'menu_id');
tests/Feature/Foundation/TenancyTest.php:5:use App\Models\StoreDomain;
tests/Feature/Foundation/TenancyTest.php:22:        ->and(StoreDomain::query()->where('hostname', 'shop.test')->exists())->toBeTrue()
tests/Feature/Foundation/TenancyTest.php:40:    StoreDomain::factory()->create([
tests/Feature/Storefront/ThemeDataTest.php:5:use App\Models\NavigationMenu;
tests/Feature/Storefront/ThemeDataTest.php:37:        ->and(NavigationMenu::withoutGlobalScopes()->count())->toBe(4)
tests/Feature/Storefront/ThemeDataTest.php:49:    NavigationMenu::factory()->create(['store_id' => $firstStore->getKey(), 'handle' => 'first-menu']);
tests/Feature/Storefront/ThemeDataTest.php:50:    NavigationMenu::factory()->create(['store_id' => $secondStore->getKey(), 'handle' => 'second-menu']);
tests/Feature/Storefront/ThemeDataTest.php:56:        ->and(NavigationMenu::query()->pluck('handle')->all())->toBe(['first-menu']);
tests/Feature/Storefront/ThemeDataTest.php:64:    $firstMenu = NavigationMenu::factory()->create(['store_id' => $firstStore->getKey()]);
tests/Feature/Storefront/ThemeDataTest.php:65:    $secondMenu = NavigationMenu::factory()->create(['store_id' => $secondStore->getKey()]);
tests/Feature/Storefront/ThemeDataTest.php:96:    $menu = NavigationMenu::withoutGlobalScopes()


Output:
Chunk ID: 325344
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 779
Output:
<?php

namespace App\Policies;

use App\Models\User;
use App\Traits\ChecksStoreRole;

class ProductPolicy
{
    use ChecksStoreRole;

    public function viewAny(User $user): bool
    {
        return $this->isAnyRole($user);
    }

    public function view(User $user, object $product): bool
    {
        return $this->isAnyRole($user, $this->storeIdForModel($product));
    }

    public function create(User $user): bool
    {
        return $this->isOwnerAdminOrStaff($user);
    }

    public function update(User $user, object $product): bool
    {
        return $this->isOwnerAdminOrStaff($user, $this->storeIdForModel($product));
    }

    public function delete(User $user, object $product): bool
    {
        return $this->isOwnerOrAdmin($user, $this->storeIdForModel($product));
    }

    public function archive(User $user, object $product): bool
    {
        return $this->delete($user, $product);
    }

    public function restore(User $user, object $product): bool
    {
        return $this->delete($user, $product);
    }
}
<?php

namespace App\Policies;

use App\Models\User;
use App\Traits\ChecksStoreRole;

class CollectionPolicy
{
    use ChecksStoreRole;

    public function viewAny(User $user): bool
    {
        return $this->isAnyRole($user);
    }

    public function view(User $user, object $collection): bool
    {
        return $this->isAnyRole($user, $this->storeIdForModel($collection));
    }

    public function create(User $user): bool
    {
        return $this->isOwnerAdminOrStaff($user);
    }

    public function update(User $user, object $collection): bool
    {
        return $this->isOwnerAdminOrStaff($user, $this->storeIdForModel($collection));
    }

    public function delete(User $user, object $collection): bool
    {
        return $this->isOwnerOrAdmin($user, $this->storeIdForModel($collection));
    }
}
<?php

namespace App\Policies;

use App\Models\User;
use App\Traits\ChecksStoreRole;

class DiscountPolicy
{
    use ChecksStoreRole;

    public function viewAny(User $user): bool
    {
        return $this->isAnyRole($user);
    }

    public function view(User $user, object $discount): bool
    {
        return $this->isAnyRole($user, $this->storeIdForModel($discount));
    }

    public function create(User $user): bool
    {
        return $this->isOwnerAdminOrStaff($user);
    }

    public function update(User $user, object $discount): bool
    {
        return $this->isOwnerAdminOrStaff($user, $this->storeIdForModel($discount));
    }

    public function delete(User $user, object $discount): bool
    {
        return $this->isOwnerOrAdmin($user, $this->storeIdForModel($discount));
    }
}
<?php

namespace App\Policies;

use App\Models\User;
use App\Traits\ChecksStoreRole;

class OrderPolicy
{
    use ChecksStoreRole;

    public function viewAny(User $user): bool
    {
        return $this->isAnyRole($user);
    }

    public function view(User $user, object $order): bool
    {
        return $this->isAnyRole($user, $this->storeIdForModel($order));
    }

    public function update(User $user, object $order): bool


sed -n '1,180p' app/Policies/StorePolicy.php


sed -n '1,220p' app/Enums/StoreDomainType.php app/Enums/TaxMode.php app/Enums/ThemeStatus.php app/Enums/PageStatus.php app/Enums/NavigationItemType.php app/Enums/ShippingRateType.php


sed -n '1,160p' app/Models/StoreDomain.php app/Models/Store.php


sed -n '1,180p' app/Policies/StorePolicy.php

<?php

namespace App\Policies;

use App\Models\Store;
use App\Models\User;
use App\Traits\ChecksStoreRole;

class StorePolicy
{
    use ChecksStoreRole;

    public function view(User $user, Store $store): bool
    {
        return $this->isAnyRole($user, $store->getKey());
    }

    public function update(User $user, Store $store): bool
    {
        return $this->isOwnerOrAdmin($user, $store->getKey());
    }

    public function delete(User $user, Store $store): bool
    {
        return $this->isOwnerOnly($user, $store->getKey());
    }
}


sed -n '1,220p' app/Enums/StoreDomainType.php app/Enums/TaxMode.php app/Enums/ThemeStatus.php app/Enums/PageStatus.php app/Enums/NavigationItemType.php app/Enums/ShippingRateType.php

<?php

namespace App\Enums;

enum StoreDomainType: string
{
    case Storefront = 'storefront';
    case Admin = 'admin';
    case Api = 'api';
}
<?php

namespace App\Enums;

enum TaxMode: string
{
    case Manual = 'manual';
    case Provider = 'provider';
}
<?php

namespace App\Enums;

enum ThemeStatus: string
{
    case Draft = 'draft';
    case Published = 'published';
}
<?php

namespace App\Enums;

enum PageStatus: string
{
    case Draft = 'draft';
    case Published = 'published';
    case Archived = 'archived';
}
<?php

namespace App\Enums;

enum NavigationItemType: string
{
    case Link = 'link';
    case Page = 'page';
    case Collection = 'collection';
    case Product = 'product';
}
<?php

namespace App\Enums;

enum ShippingRateType: string
{
    case Flat = 'flat';
    case Weight = 'weight';
    case Price = 'price';
    case Carrier = 'carrier';
}


Output:
Chunk ID: 4adb73
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 138
Output:
<?php

namespace App\Policies;

use App\Models\Store;
use App\Models\User;
use App\Traits\ChecksStoreRole;

class StorePolicy
{
    use ChecksStoreRole;

    public function view(User $user, Store $store): bool
    {
        return $this->isAnyRole($user, $store->getKey());
    }

    public function update(User $user, Store $store): bool
    {
        return $this->isOwnerOrAdmin($user, $store->getKey());
    }

    public function delete(User $user, Store $store): bool
    {
        return $this->isOwnerOnly($user, $store->getKey());
    }
}


Output:
Chunk ID: 3c8cd5
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 220
Output:
<?php

namespace App\Enums;

enum StoreDomainType: string
{
    case Storefront = 'storefront';
    case Admin = 'admin';
    case Api = 'api';
}
<?php

namespace App\Enums;

enum TaxMode: string
{
    case Manual = 'manual';
    case Provider = 'provider';
}
<?php

namespace App\Enums;

enum ThemeStatus: string
{
    case Draft = 'draft';
    case Published = 'published';
}
<?php

namespace App\Enums;

enum PageStatus: string
{
    case Draft = 'draft';
    case Published = 'published';
    case Archived = 'archived';
}
<?php

namespace App\Enums;

enum NavigationItemType: string
{
    case Link = 'link';
    case Page = 'page';
    case Collection = 'collection';
    case Product = 'product';
}
<?php

namespace App\Enums;

enum ShippingRateType: string
{
    case Flat = 'flat';
    case Weight = 'weight';
    case Price = 'price';
    case Carrier = 'carrier';
}


sed -n '1,160p' app/Models/StoreDomain.php app/Models/Store.php

<?php

namespace App\Models;

use App\Enums\StoreDomainType;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class StoreDomain extends Model
{
    /** @use HasFactory<\Database\Factories\StoreDomainFactory> */
    use HasFactory;

    public const UPDATED_AT = null;

    /**
     * @var list<string>
     */
    protected $fillable = [
        'store_id',
        'hostname',
        'type',
        'is_primary',
        'tls_mode',
    ];

    /**
     * @return BelongsTo<Store, $this>
     */
    public function store(): BelongsTo
    {
        return $this->belongsTo(Store::class);
    }

    /**
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'type' => StoreDomainType::class,
            'is_primary' => 'bool',
        ];
    }
}
<?php

namespace App\Models;

use App\Enums\StoreStatus;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;

class Store extends Model
{
    /** @use HasFactory<\Database\Factories\StoreFactory> */
    use HasFactory;

    /**
     * @var list<string>
     */
    protected $fillable = [
        'organization_id',
        'name',
        'handle',
        'status',
        'default_currency',
        'default_locale',
        'timezone',
    ];

    /**
     * @return BelongsTo<Organization, $this>
     */
    public function organization(): BelongsTo
    {
        return $this->belongsTo(Organization::class);
    }

    /**
     * @return HasMany<StoreDomain, $this>
     */
    public function domains(): HasMany
    {
        return $this->hasMany(StoreDomain::class);
    }

    /**
     * @return BelongsToMany<User, $this>
     */
    public function users(): BelongsToMany
    {
        return $this->belongsToMany(User::class, 'store_users')
            ->using(StoreUser::class)
            ->withPivot('role');
    }

    /**
     * @return HasOne<StoreSettings, $this>
     */
    public function settings(): HasOne
    {
        return $this->hasOne(StoreSettings::class);
    }

    /**
     * @return HasMany<Theme, $this>
     */
    public function themes(): HasMany
    {
        return $this->hasMany(Theme::class);
    }

    /**
     * @return HasMany<Page, $this>
     */
    public function pages(): HasMany
    {
        return $this->hasMany(Page::class);
    }

    /**
     * @return HasMany<NavigationMenu, $this>
     */
    public function navigationMenus(): HasMany
    {
        return $this->hasMany(NavigationMenu::class);
    }

    /**
     * @return HasMany<Cart, $this>
     */
    public function carts(): HasMany
    {
        return $this->hasMany(Cart::class);
    }

    /**
     * @return HasMany<Checkout, $this>
     */
    public function checkouts(): HasMany
    {
        return $this->hasMany(Checkout::class);
    }

    /**
     * @return HasMany<ShippingZone, $this>
     */
    public function shippingZones(): HasMany
    {
        return $this->hasMany(ShippingZone::class);
    }

    /**
     * @return HasOne<TaxSettings, $this>


Output:
Chunk ID: 03ebfd
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 842
Output:
<?php

namespace App\Models;

use App\Enums\StoreDomainType;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class StoreDomain extends Model
{
    /** @use HasFactory<\Database\Factories\StoreDomainFactory> */
    use HasFactory;

    public const UPDATED_AT = null;

    /**
     * @var list<string>
     */
    protected $fillable = [
        'store_id',
        'hostname',
        'type',
        'is_primary',
        'tls_mode',
    ];

    /**
     * @return BelongsTo<Store, $this>
     */
    public function store(): BelongsTo
    {
        return $this->belongsTo(Store::class);
    }

    /**
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'type' => StoreDomainType::class,
            'is_primary' => 'bool',
        ];
    }
}
<?php

namespace App\Models;

use App\Enums\StoreStatus;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;

class Store extends Model
{
    /** @use HasFactory<\Database\Factories\StoreFactory> */
    use HasFactory;

    /**
     * @var list<string>
     */
    protected $fillable = [
        'organization_id',
        'name',
        'handle',
        'status',
        'default_currency',
        'default_locale',
        'timezone',
    ];

    /**
     * @return BelongsTo<Organization, $this>
     */
    public function organization(): BelongsTo
    {
        return $this->belongsTo(Organization::class);
    }

    /**
     * @return HasMany<StoreDomain, $this>
     */
    public function domains(): HasMany
    {
        return $this->hasMany(StoreDomain::class);
    }

    /**
     * @return BelongsToMany<User, $this>
     */
    public function users(): BelongsToMany
    {
        return $this->belongsToMany(User::class, 'store_users')
            ->using(StoreUser::class)
            ->withPivot('role');
    }

    /**
     * @return HasOne<StoreSettings, $this>
     */
    public function settings(): HasOne
    {
        return $this->hasOne(StoreSettings::class);
    }

    /**
     * @return HasMany<Theme, $this>
     */
    public function themes(): HasMany
    {
        return $this->hasMany(Theme::class);
    }

    /**
     * @return HasMany<Page, $this>
     */
    public function pages(): HasMany
    {
        return $this->hasMany(Page::class);
    }

    /**
     * @return HasMany<NavigationMenu, $this>
     */
    public function navigationMenus(): HasMany
    {
        return $this->hasMany(NavigationMenu::class);
    }

    /**
     * @return HasMany<Cart, $this>
     */
    public function carts(): HasMany
    {
        return $this->hasMany(Cart::class);
    }

    /**
     * @return HasMany<Checkout, $this>
     */
    public function checkouts(): HasMany
    {
        return $this->hasMany(Checkout::class);
    }

    /**
     * @return HasMany<ShippingZone, $this>
     */
    public function shippingZones(): HasMany
    {
        return $this->hasMany(ShippingZone::class);
    }

    /**
     * @return HasOne<TaxSettings, $this>


/bin/zsh
-lc
sed -n '160,320p' app/Models/Store.php


Output:
Chunk ID: f2efac
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 0
Output:


sed -n '1,180p' resources/views/layouts/app/sidebar.blade.php


sed -n '1,180p' resources/views/layouts/app/sidebar.blade.php

<!DOCTYPE html>
getLocale()) }}" class="dark">

        @include('partials.head')

        <flux:sidebar sticky collapsible="mobile" class="border-e border-zinc-200 bg-zinc-50 dark:border-zinc-700 dark:bg-zinc-900">
            <flux:sidebar.header>
                <x-app-logo :sidebar="true" href="{{ route('admin.dashboard') }}" wire:navigate />
                <flux:sidebar.collapse class="lg:hidden" />
            </flux:sidebar.header>

            <flux:sidebar.nav>
                <flux:sidebar.group :heading="__('Platform')" class="grid">
                    <flux:sidebar.item icon="home" :href="route('admin.dashboard')" :current="request()->routeIs('admin.dashboard')" wire:navigate>
                        {{ __('Dashboard') }}
                    </flux:sidebar.item>
                </flux:sidebar.group>

                <flux:sidebar.group :heading="__('Products')" class="grid">
                    <flux:sidebar.item icon="cube" :href="route('admin.products.index')" :current="request()->routeIs('admin.products.*')" wire:navigate>
                        {{ __('Products') }}
                    </flux:sidebar.item>

                    <flux:sidebar.item icon="rectangle-stack" :href="route('admin.collections.index')" :current="request()->routeIs('admin.collections.*')" wire:navigate>
                        {{ __('Collections') }}
                    </flux:sidebar.item>

                    <flux:sidebar.item icon="archive-box" :href="route('admin.inventory.index')" :current="request()->routeIs('admin.inventory.*')" wire:navigate>
                        {{ __('Inventory') }}
                    </flux:sidebar.item>
                </flux:sidebar.group>

                <flux:sidebar.group :heading="__('Operations')" class="grid">
                    <flux:sidebar.item icon="shopping-bag" :href="route('admin.orders.index')" :current="request()->routeIs('admin.orders.*')" wire:navigate>
                        {{ __('Orders') }}
                    </flux:sidebar.item>

                    <flux:sidebar.item icon="users" :href="route('admin.customers.index')" :current="request()->routeIs('admin.customers.*')" wire:navigate>
                        {{ __('Customers') }}
                    </flux:sidebar.item>

                    <flux:sidebar.item icon="tag" :href="route('admin.discounts.index')" :current="request()->routeIs('admin.discounts.*')" wire:navigate>
                        {{ __('Discounts') }}
                    </flux:sidebar.item>
                </flux:sidebar.group>
            </flux:sidebar.nav>

            <flux:spacer />

            <flux:sidebar.nav>
                <flux:sidebar.item icon="folder-git-2" href="https://github.com/laravel/livewire-starter-kit" target="_blank">
                    {{ __('Repository') }}
                </flux:sidebar.item>

                <flux:sidebar.item icon="book-open-text" href="https://laravel.com/docs/starter-kits#livewire" target="_blank">
                    {{ __('Documentation') }}
                </flux:sidebar.item>
            </flux:sidebar.nav>

            <x-desktop-user-menu class="hidden lg:block" :name="auth()->user()->name" />
        </flux:sidebar>

        <flux:header class="lg:hidden">
            <flux:sidebar.toggle class="lg:hidden" icon="bars-2" inset="left" />

            <flux:spacer />

            <flux:dropdown position="top" align="end">
                <flux:profile
                    :initials="auth()->user()->initials()"
                    icon-trailing="chevron-down"
                />

                <flux:menu>
                    <flux:menu.radio.group>

                                <flux:avatar
                                    :name="auth()->user()->name"
                                    :initials="auth()->user()->initials()"
                                />

                                    <flux:heading class="truncate">{{ auth()->user()->name }}</flux:heading>
                                    <flux:text class="truncate">{{ auth()->user()->email }}</flux:text>

                    </flux:menu.radio.group>

                    <flux:menu.separator />

                    <flux:menu.radio.group>
                        <flux:menu.item :href="route('profile.edit')" icon="cog" wire:navigate>
                            {{ __('Settings') }}
                        </flux:menu.item>
                    </flux:menu.radio.group>

                    <flux:menu.separator />

                    <form method="POST" action="{{ route('logout') }}" class="w-full">
                        @csrf
                        <flux:menu.item
                            as="button"
                            type="submit"
                            icon="arrow-right-start-on-rectangle"
                            class="w-full cursor-pointer"
                            data-test="logout-button"
                        >
                            {{ __('Log Out') }}
                        </flux:menu.item>
                    </form>
                </flux:menu>
            </flux:dropdown>
        </flux:header>

        {{ $slot }}

        @fluxScripts


Output:
Chunk ID: 7f9b4e
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 1425
Output:
<!DOCTYPE html>
getLocale()) }}" class="dark">

        @include('partials.head')

        <flux:sidebar sticky collapsible="mobile" class="border-e border-zinc-200 bg-zinc-50 dark:border-zinc-700 dark:bg-zinc-900">
            <flux:sidebar.header>
                <x-app-logo :sidebar="true" href="{{ route('admin.dashboard') }}" wire:navigate />
                <flux:sidebar.collapse class="lg:hidden" />
            </flux:sidebar.header>

            <flux:sidebar.nav>
                <flux:sidebar.group :heading="__('Platform')" class="grid">
                    <flux:sidebar.item icon="home" :href="route('admin.dashboard')" :current="request()->routeIs('admin.dashboard')" wire:navigate>
                        {{ __('Dashboard') }}
                    </flux:sidebar.item>
                </flux:sidebar.group>

                <flux:sidebar.group :heading="__('Products')" class="grid">
                    <flux:sidebar.item icon="cube" :href="route('admin.products.index')" :current="request()->routeIs('admin.products.*')" wire:navigate>
                        {{ __('Products') }}
                    </flux:sidebar.item>

                    <flux:sidebar.item icon="rectangle-stack" :href="route('admin.collections.index')" :current="request()->routeIs('admin.collections.*')" wire:navigate>
                        {{ __('Collections') }}
                    </flux:sidebar.item>

                    <flux:sidebar.item icon="archive-box" :href="route('admin.inventory.index')" :current="request()->routeIs('admin.inventory.*')" wire:navigate>
                        {{ __('Inventory') }}
                    </flux:sidebar.item>
                </flux:sidebar.group>

                <flux:sidebar.group :heading="__('Operations')" class="grid">
                    <flux:sidebar.item icon="shopping-bag" :href="route('admin.orders.index')" :current="request()->routeIs('admin.orders.*')" wire:navigate>
                        {{ __('Orders') }}
                    </flux:sidebar.item>

                    <flux:sidebar.item icon="users" :href="route('admin.customers.index')" :current="request()->routeIs('admin.customers.*')" wire:navigate>
                        {{ __('Customers') }}
                    </flux:sidebar.item>

                    <flux:sidebar.item icon="tag" :href="route('admin.discounts.index')" :current="request()->routeIs('admin.discounts.*')" wire:navigate>
                        {{ __('Discounts') }}
                    </flux:sidebar.item>
                </flux:sidebar.group>
            </flux:sidebar.nav>

            <flux:spacer />

            <flux:sidebar.nav>
                <flux:sidebar.item icon="folder-git-2" href="https://github.com/laravel/livewire-starter-kit" target="_blank">
                    {{ __('Repository') }}
                </flux:sidebar.item>

                <flux:sidebar.item icon="book-open-text" href="https://laravel.com/docs/starter-kits#livewire" target="_blank">
                    {{ __('Documentation') }}
                </flux:sidebar.item>
            </flux:sidebar.nav>

            <x-desktop-user-menu class="hidden lg:block" :name="auth()->user()->name" />
        </flux:sidebar>

        <flux:header class="lg:hidden">
            <flux:sidebar.toggle class="lg:hidden" icon="bars-2" inset="left" />

            <flux:spacer />

            <flux:dropdown position="top" align="end">
                <flux:profile
                    :initials="auth()->user()->initials()"
                    icon-trailing="chevron-down"
                />

                <flux:menu>
                    <flux:menu.radio.group>

                                <flux:avatar
                                    :name="auth()->user()->name"
                                    :initials="auth()->user()->initials()"
                                />

                                    <flux:heading class="truncate">{{ auth()->user()->name }}</flux:heading>
                                    <flux:text class="truncate">{{ auth()->user()->email }}</flux:text>

                    </flux:menu.radio.group>

                    <flux:menu.separator />

                    <flux:menu.radio.group>
                        <flux:menu.item :href="route('profile.edit')" icon="cog" wire:navigate>
                            {{ __('Settings') }}
                        </flux:menu.item>
                    </flux:menu.radio.group>

                    <flux:menu.separator />

                    <form method="POST" action="{{ route('logout') }}" class="w-full">
                        @csrf
                        <flux:menu.item
                            as="button"
                            type="submit"
                            icon="arrow-right-start-on-rectangle"
                            class="w-full cursor-pointer"
                            data-test="logout-button"
                        >
                            {{ __('Log Out') }}
                        </flux:menu.item>
                    </form>
                </flux:menu>
            </flux:dropdown>
        </flux:header>

        {{ $slot }}

        @fluxScripts


sed -n '1,220p' database/seeders/ThemeSettingsSeeder.php database/seeders/ThemeFileSeeder.php database/seeders/ThemeSeeder.php


sed -n '1,220p' database/seeders/PageSeeder.php database/seeders/NavigationMenuSeeder.php database/seeders/NavigationItemSeeder.php database/seeders/StoreSettingsSeeder.php database/seeders/TaxSettingsSeeder.php database/seeders/ShippingZoneSeeder.php database/seeders/ShippingRateSeeder.php


sed -n '1,220p' app/Services/ThemeSettingsService.php app/Services/NavigationService.php app/Services/ShippingCalculator.php


sed -n '1,220p' database/seeders/ThemeSettingsSeeder.php database/seeders/ThemeFileSeeder.php database/seeders/ThemeSeeder.php

<?php

namespace Database\Seeders;

use App\Models\Theme;
use App\Models\ThemeSettings;
use App\Services\ThemeSettingsService;
use Illuminate\Database\Seeder;

class ThemeSettingsSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        Theme::withoutGlobalScopes()
            ->with('store')
            ->get()
            ->each(function (Theme $theme): void {
                ThemeSettings::withoutGlobalScopes()->updateOrCreate(
                    ['theme_id' => $theme->getKey()],
                    [
                        'settings_json' => app(ThemeSettingsService::class)->defaultsForStore($theme->store),
                        'updated_at' => now(),
                    ],
                );
            });
    }
}
<?php

namespace Database\Seeders;

use App\Models\Theme;
use App\Models\ThemeFile;
use Illuminate\Database\Seeder;

class ThemeFileSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        Theme::withoutGlobalScopes()->get()->each(function (Theme $theme): void {
            foreach ([
                'layouts/storefront.blade.php',
                'sections/hero.blade.php',
                'sections/featured-products.blade.php',
            ] as $path) {
                ThemeFile::withoutGlobalScopes()->updateOrCreate(
                    [
                        'theme_id' => $theme->getKey(),
                        'path' => $path,
                    ],
                    [
                        'storage_key' => "themes/{$theme->getKey()}/{$path}",
                        'sha256' => hash('sha256', "{$theme->getKey()}:{$path}"),
                        'byte_size' => 1024,
                    ],
                );
            }
        });
    }
}
<?php

namespace Database\Seeders;

use App\Models\Store;
use App\Models\Theme;
use Illuminate\Database\Seeder;

class ThemeSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        Store::query()->orderBy('id')->get()->each(function (Store $store): void {
            Theme::withoutGlobalScopes()->updateOrCreate(
                [
                    'store_id' => $store->getKey(),
                    'name' => "{$store->name} Default",
                ],
                [
                    'version' => '1.0.0',
                    'status' => 'published',
                    'published_at' => now(),
                ],
            );
        });
    }
}


sed -n '1,220p' database/seeders/PageSeeder.php database/seeders/NavigationMenuSeeder.php database/seeders/NavigationItemSeeder.php database/seeders/StoreSettingsSeeder.php database/seeders/TaxSettingsSeeder.php database/seeders/ShippingZoneSeeder.php database/seeders/ShippingRateSeeder.php

<?php

namespace Database\Seeders;

use App\Models\Page;
use App\Models\Store;
use Illuminate\Database\Seeder;

class PageSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        Store::query()->get()->each(function (Store $store): void {
            foreach ($this->pagesFor($store) as $page) {
                Page::withoutGlobalScopes()->updateOrCreate(
                    [
                        'store_id' => $store->getKey(),
                        'handle' => $page['handle'],
                    ],
                    [
                        'title' => $page['title'],
                        'body_html' => $page['body_html'],
                        'status' => 'published',
                        'published_at' => now(),
                    ],
                );
            }
        });
    }

    /**
     * @return array<int, array{handle: string, title: string, body_html: string}>
     */
    private function pagesFor(Store $store): array
    {
        return [
            [
                'handle' => 'about',
                'title' => 'About',
                'body_html' => "
{$store->name} is the demo storefront for this self-contained shop platform.

The catalog includes multi-variant products, sale pricing, inventory rules, backorder handling, and digital product examples for checkout and storefront testing.
",
            ],
            [
                'handle' => 'faq',
                'title' => 'FAQ',
                'body_html' => '
Shipping, payment, returns, and account flows are implemented progressively according to the project roadmap.
',
            ],
            [
                'handle' => 'shipping',
                'title' => 'Shipping',
                'body_html' => '
Shipping zones, rates, and tax-aware checkout calculations are seeded in the checkout phase.
',
            ],
        ];
    }
}
<?php

namespace Database\Seeders;

use App\Models\NavigationMenu;
use App\Models\Store;
use Illuminate\Database\Seeder;

class NavigationMenuSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        Store::query()->get()->each(function (Store $store): void {
            foreach ([
                'main-menu' => 'Main Menu',
                'footer-menu' => 'Footer Menu',
            ] as $handle => $title) {
                NavigationMenu::withoutGlobalScopes()->updateOrCreate(
                    [
                        'store_id' => $store->getKey(),
                        'handle' => $handle,
                    ],
                    ['title' => $title],
                );
            }
        });
    }
}
<?php

namespace Database\Seeders;

use App\Models\Collection as ProductCollection;
use App\Models\NavigationItem;
use App\Models\NavigationMenu;
use App\Models\Page;
use App\Models\Store;
use Illuminate\Database\Seeder;

class NavigationItemSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        Store::query()->get()->each(function (Store $store): void {
            $menus = NavigationMenu::withoutGlobalScopes()
                ->where('store_id', $store->getKey())
                ->get()
                ->keyBy('handle');

            $this->replaceItems($menus->get('main-menu'), $this->mainMenuItems($store));
            $this->replaceItems($menus->get('footer-menu'), $this->footerMenuItems($store));
        });
    }

    /**
     * @param  array<int, array{label: string, type: string, url?: string|null, resource_id?: int|null}>  $items
     */
    private function replaceItems(?NavigationMenu $menu, array $items): void
    {
        if ($menu === null) {
            return;
        }

        NavigationItem::withoutGlobalScopes()
            ->where('menu_id', $menu->getKey())
            ->delete();

        foreach ($items as $position => $item) {
            NavigationItem::withoutGlobalScopes()->create([
                'menu_id' => $menu->getKey(),
                'type' => $item['type'],
                'label' => $item['label'],
                'url' => $item['url'] ?? null,
                'resource_id' => $item['resource_id'] ?? null,
                'position' => $position,
            ]);
        }
    }

    /**
     * @return array<int, array{label: string, type: string, url?: string|null, resource_id?: int|null}>
     */
    private function mainMenuItems(Store $store): array
    {
        $newArrivals = $this->collection($store, 'new-arrivals') ?? $this->collection($store, 'featured');
        $secondaryCollection = $this->collection($store, 't-shirts') ?? $this->collection($store, 'accessories');
        $about = $this->page($store, 'about');

        return array_values(array_filter([
            ['label' => 'Collections', 'type' => 'link', 'url' => '/collections'],
            $newArrivals ? ['label' => $newArrivals->title, 'type' => 'collection', 'resource_id' => $newArrivals->getKey()] : null,
            $secondaryCollection ? ['label' => $secondaryCollection->title, 'type' => 'collection', 'resource_id' => $secondaryCollection->getKey()] : null,
            ['label' => 'Search', 'type' => 'link', 'url' => '/search'],
            $about ? ['label' => 'About', 'type' => 'page', 'resource_id' => $about->getKey()] : null,
        ]));
    }

    /**
     * @return array<int, array{label: string, type: string, url?: string|null, resource_id?: int|null}>
     */
    private function footerMenuItems(Store $store): array
    {
        $sale = $this->collection($store, 'sale');
        $about = $this->page($store, 'about');
        $faq = $this->page($store, 'faq');

        return array_values(array_filter([
            $sale ? ['label' => 'Sale', 'type' => 'collection', 'resource_id' => $sale->getKey()] : null,
            $about ? ['label' => 'About', 'type' => 'page', 'resource_id' => $about->getKey()] : null,
            $faq ? ['label' => 'FAQ', 'type' => 'page', 'resource_id' => $faq->getKey()] : null,
            ['label' => 'Account', 'type' => 'link', 'url' => '/account'],
        ]));
    }

    private function collection(Store $store, string $handle): ?ProductCollection
    {
        return ProductCollection::withoutGlobalScopes()
            ->where('store_id', $store->getKey())
            ->where('handle', $handle)
            ->first();
    }

    private function page(Store $store, string $handle): ?Page
    {
        return Page::withoutGlobalScopes()
            ->where('store_id', $store->getKey())
            ->where('handle', $handle)
            ->first();
    }
}
<?php

namespace Database\Seeders;

use App\Models\Store;
use App\Models\StoreSettings;
use Illuminate\Database\Seeder;

class StoreSettingsSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        Store::query()->each(function (Store $store): void {
            StoreSettings::query()->updateOrCreate(
                ['store_id' => $store->getKey()],
                [
                    'settings_json' => [
                        'announcement' => [
                            'enabled' => true,
                            'text' => 'Free shipping on orders over 75.00 EUR',
                        ],
                        'checkout' => [
                            'guest_checkout_enabled' => true,
                        ],