HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/slenders.komma.pro/app/Komma/Shop/Properties/Kms/PropertyController.php
<?php
namespace App\Komma\Shop\Properties\Kms;

use App\Komma\Kms\Core\SectionController;
use App\Komma\Shop\Properties\Models\Api\PropertyResource;
use App\Komma\Shop\Properties\Models\Property;
use Illuminate\Http\Request;

class PropertyController extends SectionController
{
    protected $slug = "properties";
    protected $forModelName = Property::class;

    /** @var PropertyService $propertyService */
    protected $propertyService;

    public function __construct(PropertySection $section)
    {
        parent::__construct($section);
        $this->propertyService = app(PropertyService::class); //Add interface in future
    }

    /**
     * For ajax requests
     *
     * @param Request $request
     * @param string $keyTranslationValue
     *
     * @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
     * @see PropertyService::getPropertiesForPropertyKeyValue()
     */
    public function getPropertiesForPropertyKeyValue(Request $request, string $keyTranslationValue)
    {
        if(!$request->ajax()) abort(403);
        $propertiesCollection = $this->propertyService->getPropertiesForPropertyKeyValue($keyTranslationValue)->get();
        return PropertyResource::collection($propertiesCollection);
    }
}