<?php

namespace App\Actions\Tenancy;

use App\Models\Tenancy\Warehouse;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\Facades\Cache;

class GetProductsAction
{
    public function execute(): Collection
    {
        $key = config('redis-keys.get_products_cache');

        return Cache::get($key, function () {
            return Warehouse::where('is_realization', 1)
                ->where('status', 'default')
                ->where('quantity', '>', 0)
                ->orderBy('name')
                ->get();
        });
    }
}
