File: D:/HostingSpaces/egovers/edwingovers.nl/app/KommaApp/Shop/Properties/Kms/PropertyController.php
<?php
namespace App\KommaApp\Shop\Properties\Kms;
use App\KommaApp\Kms\Core\SectionController;
use App\KommaApp\Shop\Properties\Models\Api\PropertyResource;
use App\KommaApp\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::make(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);
}
}