Files
cheerstothe_season_2.0/app/Services/APIs/CustomerAPIs/RestaurantApiServices.php
2024-05-28 18:52:27 +05:30

53 lines
1.5 KiB
PHP

<?php
namespace App\Services\APIs\CustomerAPIs;
use App\Models\ManageRestaurant;
use Exception;
use Illuminate\Support\Facades\Log;
class RestaurantApiServices
{
public function getRestaurant($customerIamId)
{
try {
$restaurant = ManageRestaurant::with([
'operatingHours' => function ($query) {
$query->select('id', 'day_of_week', 'start_time', 'end_time', 'manage_restaurant_xid');
},
])
->select(
'id',
'name',
'description',
'address',
'image',
'bio',
'try_on_1',
'try_on_2',
'try_on_3',
'try_on_4',
'exclusion',
'latitude',
'longtitude'
)
->where('is_active', '1')
->get()
->toArray();
foreach ($restaurant as &$res) {
$res['image'] = ListingImageUrl('restaurant_images', $res['image']);
}
return jsonResponseWithSuccessMessage(__('auth.data_fetched_successfully'), $restaurant, 200);
} catch (Exception $ex) {
Log::error('Restaurant Get service failed : ' . $ex->getMessage());
return jsonResponseWithErrorMessageApi(__('auth.something_went_wrong'), 500);
}
}
}