File: D:/HostingSpaces/SBogers10/topswtw.komma.pro/app/KommaApp/Shop/ShopRepository.php
<?php
namespace KommaApp\Shop;
class ShopRepository
{
/**
* @param $shopId
* @return mixed
*/
public function getShop($shopId)
{
return \DB::table('shops')
->where('id', '=', $shopId)
->select('*')
->first();
}
/*
* @returns Object
*/
public function getShopWithDomainByDomain(Domain $domain)
{
return \DB::table('shops')
->join('domains', 'shops.id', '=', 'domains.shop_id')
->where('domains.domain', '=', $domain->get())
->first();
}
/*
* @returns Array
*/
public function getShopsWithLanguageById($shopId = null)
{
$shopLanguages = \DB::table('shops')
->join('shop_language', 'shops.id', '=', 'shop_language.shop_id')
->join('languages', 'languages.id', '=', 'shop_language.language_id')
->select('shops.id', 'shops.default_language_id', 'languages.id as language_id', 'languages.iso_2 as language_slug');
if ($shopId) {
$shopLanguages = $shopLanguages->where('shop_language.shop_id', '=', $shopId);
}
return $shopLanguages->get();
}
public function getShopCountry($shopId)
{
return \DB::table('shops')
->join('countries', 'shops.country_id', '=', 'countries.id')
->select('countries.name', 'countries.iso_2')
->where('shops.id', '=', $shopId)
->first();
}
}