QueenFruits/Backend/app/Http/Controllers/Api/HomeController.php

55 lines
1.2 KiB
PHP

<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Services\HomeService;
use App\Traits\ApiResponse;
use Illuminate\Http\Request;
class HomeController extends Controller
{
use ApiResponse;
protected $homeService;
public function __construct(HomeService $homeService)
{
$this->homeService = $homeService;
}
public function home($outletId)
{
try {
$data = $this->homeService->home($outletId);
return $this->successResponse($data);
} catch(\Exception $e) {
return $this->errorResponse(errorDetails: $e->getMessage());
}
}
public function getOutlets()
{
try {
$data = $this->homeService->getOutlets();
return $this->successResponse($data);
} catch(\Exception $e) {
return $this->errorResponse(errorDetails: $e->getMessage());
}
}
public function getMainOutlet()
{
try {
$data = $this->homeService->getMainOutlet();
return $this->successResponse($data);
} catch(\Exception $e) {
return $this->errorResponse(errorDetails: $e->getMessage());
}
}
}