added featured products

This commit is contained in:
franknstayn
2021-07-23 20:42:59 +08:00
parent 13509568eb
commit a6ea024725
6 changed files with 178 additions and 134 deletions

View File

@@ -161,10 +161,13 @@ class TeamStoreController extends Controller
$stores_array = $m->selectTeamstoreFilter($field, $sort_value); $stores_array = $m->selectTeamstoreFilter($field, $sort_value);
} }
$featured_products = $m->selectFeaturedProducts();
return view('merchbay.index') return view('merchbay.index')
->with('stores_array', $stores_array) ->with('stores_array', $stores_array)
->with('keyword', $q) ->with('keyword', $q)
->with('filter', $sort); ->with('filter', $sort)
->with('featured_products', $featured_products);
} }
public function checkTeamStorePassword(Request $request) public function checkTeamStorePassword(Request $request)
@@ -233,6 +236,8 @@ class TeamStoreController extends Controller
$availableQty = null; $availableQty = null;
} }
// $product_array[0]->ProductAvailableQty // $product_array[0]->ProductAvailableQty
// var_dump($store_array[0]->Id);
$store_products = $m->selectFeaturedProducts($store_array[0]->Id);
return view('teamstore-sublayouts.product-details') return view('teamstore-sublayouts.product-details')
->with('store_array', $store_array) ->with('store_array', $store_array)
@@ -240,7 +245,8 @@ class TeamStoreController extends Controller
->with('thumbnails_array', $thumbnails_array) ->with('thumbnails_array', $thumbnails_array)
->with('teams_array', $teams_array) ->with('teams_array', $teams_array)
->with('sizes_array', $sizes_array) ->with('sizes_array', $sizes_array)
->with('available_qty', $availableQty); ->with('available_qty', $availableQty)
->with('store_products', $store_products);
} }
public function login(Request $request) public function login(Request $request)

View File

@@ -1,7 +1,7 @@
<?php namespace App\Models\designer; <?php namespace App\Models\designer;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use DB; use Illuminate\Support\Facades\DB;
class DesignerModel extends Model { class DesignerModel extends Model {

View File

@@ -1,241 +1,273 @@
<?php namespace App\Models\teamstore; <?php
namespace App\Models\teamstore;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
class TeamStoreModel extends Model { class TeamStoreModel extends Model
{
function selectAllTeamStore() // display all data from database function selectAllTeamStore() // display all data from database
{ {
$i = DB::table('teamstores') $i = DB::table('teamstores')
->where("IsActive", "true") ->where("IsActive", "true")
->orderBy('Id', 'DESC') ->orderBy('Id', 'DESC')
->paginate(16); ->paginate(16);
return $i; return $i;
} }
function selectTeamStoreProducts($field, $teamstoreId) // display all data from database function selectTeamStoreProducts($field, $teamstoreId) // display all data from database
{ {
$i = DB::table('teamstore_products') $i = DB::table('teamstore_products')
->where($field, $teamstoreId) ->where($field, $teamstoreId)
// ->orderBy('Ordering', 'ASC') // ->orderBy('Ordering', 'ASC')
->orderBy('Ordering', 'ASC')->get(); ->orderBy('Ordering', 'ASC')->get();
return $i; return $i;
} }
function selectTeamStoreProductByIdHash($id) function selectTeamStoreProductByIdHash($id)
{ {
$i = DB::table('teamstore_products') $i = DB::table('teamstore_products')
->where(DB::raw('md5(Id)') , $id) ->where(DB::raw('md5(Id)'), $id)
->get(); ->get();
return $i; return $i;
} }
function selectTeamStore($field, $teamstoreURL) function selectTeamStore($field, $teamstoreURL)
{ {
$i = DB::table('teamstores') $i = DB::table('teamstores')
->where($field, $teamstoreURL) ->where($field, $teamstoreURL)
->get(); ->get();
return $i; return $i;
} }
function checkStorePassword($storeid, $password) function checkStorePassword($storeid, $password)
{ {
$i = DB::table('teamstores') $i = DB::table('teamstores')
->where('Id', $storeid) ->where('Id', $storeid)
->where('Password', $password) ->where('Password', $password)
->get(); ->get();
return $i; return $i;
} }
function selectTeamStoreGroupByCartKey($cartKey) function selectTeamStoreGroupByCartKey($cartKey)
{ {
$i = DB::table('cart_tmp') $i = DB::table('cart_tmp')
->where('CartKey', $cartKey) ->where('CartKey', $cartKey)
->groupby('CartKey') ->groupby('CartKey')
->get(); ->get();
return $i;
}
function getProductThumbnails($productId){
$i = DB::table('teamstore_product_thumbnails')
->where('ProductId', $productId)
->orderby('Ordering', 'ASC')
->get();
return $i; return $i;
} }
function insertTeamStoreProduct($item_details){ function getProductThumbnails($productId)
{
$i = DB::table('teamstore_product_thumbnails')
->where('ProductId', $productId)
->orderby('Ordering', 'ASC')
->get();
return $i;
}
function insertTeamStoreProduct($item_details)
{
$i = DB::table('teamstore_products')->insert($item_details); $i = DB::table('teamstore_products')->insert($item_details);
$id = DB::getPdo()->lastInsertId(); $id = DB::getPdo()->lastInsertId();
return array( return array(
'i' => $i, 'i' => $i,
'lastId' => $id 'lastId' => $id
); );
} }
function insertTeamStoreProductThumbnails($item_details){ function insertTeamStoreProductThumbnails($item_details)
{
$i = DB::table('teamstore_product_thumbnails')->insert($item_details); $i = DB::table('teamstore_product_thumbnails')->insert($item_details);
return $i; return $i;
} }
function getThumbnails($productId){ function getThumbnails($productId)
{
$i = DB::table('teamstore_product_thumbnails') $i = DB::table('teamstore_product_thumbnails')
->where('ProductId', $productId) ->where('ProductId', $productId)
->orderby('Ordering', 'ASC') ->orderby('Ordering', 'ASC')
->get(); ->get();
return $i; return $i;
} }
function getTeams($productId){ function getTeams($productId)
{
$i = DB::table('teams')->where('ProductId', $productId)->get(); $i = DB::table('teams')->where('ProductId', $productId)->get();
return $i; return $i;
} }
function getSizes(){ function getSizes()
{
$i = DB::table('sizes') $i = DB::table('sizes')
->where('IsActive', 'TRUE') ->where('IsActive', 'TRUE')
->orderby('Ordering', 'ASC') ->orderby('Ordering', 'ASC')
->get(); ->get();
return $i; return $i;
} }
function getSizesByBracket($bracket){ function getSizesByBracket($bracket)
{
$i = DB::table('sizes')->select('Size', 'SizeDisplay') $i = DB::table('sizes')->select('Size', 'SizeDisplay')
->where('Bracket', $bracket) ->where('Bracket', $bracket)
->where('IsActive', 'TRUE') ->where('IsActive', 'TRUE')
->orderby('Ordering', 'ASC') ->orderby('Ordering', 'ASC')
->get(); ->get();
return $i; return $i;
} }
function insertToCart($data){ function insertToCart($data)
{
$i = DB::table('cart_tmp')->insert($data); $i = DB::table('cart_tmp')->insert($data);
$id = DB::getPdo()->lastInsertId(); $id = DB::getPdo()->lastInsertId();
return array( return array(
'i' => $i, 'i' => $i,
'lastId' => $id 'lastId' => $id
); );
// return $i; // return $i;
} }
function selectDisplayCartThumb(){ function selectDisplayCartThumb()
{
$i = DB::table('teamstore_product_thumbnails') $i = DB::table('teamstore_product_thumbnails')
->where('ImageClass', 'active') ->where('ImageClass', 'active')
->get(); ->get();
return $i; return $i;
} }
function myCart($cartKey){ function myCart($cartKey)
{
// echo $cartKey; // echo $cartKey;
if($cartKey != ""){ if ($cartKey != "") {
$i = DB::table('cart_tmp') $i = DB::table('cart_tmp')
->leftjoin('teamstore_voucher', 'cart_tmp.VoucherId', '=', 'teamstore_voucher.Id') ->leftjoin('teamstore_voucher', 'cart_tmp.VoucherId', '=', 'teamstore_voucher.Id')
->select('cart_tmp.*', 'teamstore_voucher.VoucherCode', 'teamstore_voucher.VoucherType', 'teamstore_voucher.VoucherValue', 'teamstore_voucher.VoucherExpiryDate', 'teamstore_voucher.Status') ->select('cart_tmp.*', 'teamstore_voucher.VoucherCode', 'teamstore_voucher.VoucherType', 'teamstore_voucher.VoucherValue', 'teamstore_voucher.VoucherExpiryDate', 'teamstore_voucher.Status')
->where('cart_tmp.CartKey', $cartKey) ->where('cart_tmp.CartKey', $cartKey)
->get(); ->get();
// var_dump($i); // var_dump($i);
return $i; return $i;
} }
} }
function myCartGroup($cartKey){ function myCartGroup($cartKey)
if($cartKey != ""){ {
if ($cartKey != "") {
$pdo = DB::connection()->getPdo(); $pdo = DB::connection()->getPdo();
$query = $pdo->prepare("SELECT *, COUNT(Id) AS qty, Price * SUM(Quantity) AS total_price FROM cart_tmp WHERE CartKey = :ck GROUP BY ProductId"); $query = $pdo->prepare("SELECT *, COUNT(Id) AS qty, Price * SUM(Quantity) AS total_price FROM cart_tmp WHERE CartKey = :ck GROUP BY ProductId");
$query->execute([':ck'=>$cartKey]); $query->execute([':ck' => $cartKey]);
$row = $query->fetchAll(\PDO::FETCH_OBJ); $row = $query->fetchAll(\PDO::FETCH_OBJ);
return $row; return $row;
} }
} }
function getSubtotal($cartKey){ function getSubtotal($cartKey)
{
$i = DB::table('cart_tmp')->select(DB::raw('SUM(Quantity * Price) AS Subtotal')) $i = DB::table('cart_tmp')->select(DB::raw('SUM(Quantity * Price) AS Subtotal'))
->where('CartKey','=',$cartKey) ->where('CartKey', '=', $cartKey)
->get(); ->get();
return $i; return $i;
} }
function updateStoreItem($data, $url){ function updateStoreItem($data, $url)
{
$i = DB::table('teamstore_products')->where('ProductURL', $url) $i = DB::table('teamstore_products')->where('ProductURL', $url)
->update($data); ->update($data);
return $i; return $i;
} }
function getSoldQty($productId){ function getSoldQty($productId)
{
$i = DB::table('orders')->select(DB::raw('SUM(Quantity) AS SoldQty')) $i = DB::table('orders')->select(DB::raw('SUM(Quantity) AS SoldQty'))
->where('ProductId', $productId) ->where('ProductId', $productId)
->get(); ->get();
return $i;
}
function selectVoucher($data){
$i = DB::table('teamstore_voucher')
->where(DB::raw('BINARY `VoucherCode`'), $data['voucher'])
->where('TeamStoreId', $data['store_id'])
->get();
return $i; return $i;
} }
function selectVoucherWhereIn($data){ function selectVoucher($data)
{
$i = DB::table('teamstore_voucher') $i = DB::table('teamstore_voucher')
->whereIn('Id', $data) ->where(DB::raw('BINARY `VoucherCode`'), $data['voucher'])
->get(); ->where('TeamStoreId', $data['store_id'])
->get();
return $i; return $i;
} }
function updateVoucherValueInCart($data, $id){ function selectVoucherWhereIn($data)
{
$i = DB::table('teamstore_voucher')
->whereIn('Id', $data)
->get();
return $i;
}
function updateVoucherValueInCart($data, $id)
{
$i = DB::table('cart_tmp') $i = DB::table('cart_tmp')
->where('Id', $id) ->where('Id', $id)
->update($data); ->update($data);
return $i; return $i;
} }
function selectTeamstoreSearch($field, $value, $keyword){ function selectTeamstoreSearch($field, $value, $keyword)
{
$i = DB::table('teamstores') $i = DB::table('teamstores')
->where("StoreName", "LIKE","%$keyword%") ->where("StoreName", "LIKE", "%$keyword%")
->where("IsActive", "true") ->where("IsActive", "true")
->orderby($field, $value) ->orderby($field, $value)
->paginate(16); ->paginate(16);
return $i; return $i;
} }
function selectTeamstoreFilter($field, $value){ function selectTeamstoreFilter($field, $value)
{
$i = DB::table('teamstores') $i = DB::table('teamstores')
->where("IsActive", "true") ->where("IsActive", "true")
->orderby($field, $value) ->orderby($field, $value)
->paginate(12); ->paginate(12);
return $i; return $i;
} }
function selectFeaturedProduct(){ function selectFeaturedProducts($store_id = 0)
{
$i = DB::table('teamstore_products') if($store_id == 0){
->where("IsActive", "true") $i = DB::select("SELECT t.StoreUrl, tp.ProductName, tp.ProductPrice, tp.ProductURL, tpt.Image FROM teamstores AS t
// ->orderby($field, $value) INNER JOIN teamstore_products AS tp ON tp.TeamStoreId = t.Id
->paginate(12); INNER JOIN teamstore_product_thumbnails as tpt ON tp.Id = tpt.ProductId
WHERE t.Password IS NULL AND t.IsHibernated IS NULL AND tpt.ImageClass = 'active' AND tp.PrivacyStatus = 'public'
ORDER BY RAND()
LIMIT 6");
} else{
$i = DB::select("SELECT t.StoreUrl, tp.ProductName, tp.ProductPrice, tp.ProductURL, tpt.Image FROM teamstores AS t
INNER JOIN teamstore_products AS tp ON tp.TeamStoreId = t.Id
INNER JOIN teamstore_product_thumbnails as tpt ON tp.Id = tpt.ProductId
WHERE t.Password IS NULL AND t.IsHibernated IS NULL AND tpt.ImageClass = 'active' AND tp.PrivacyStatus = 'public' AND t.Id = $store_id
ORDER BY RAND()
LIMIT 6");
}
return $i; return $i;
} }
} }

View File

@@ -7,6 +7,10 @@ body {
font-size: 0.9rem; font-size: 0.9rem;
} }
a {
text-decoration: none;
}
.bg-black { .bg-black {
background-color: #000; background-color: #000;
} }
@@ -196,6 +200,7 @@ li.footer-menu-item a:hover {
font-size: 0.8rem; font-size: 0.8rem;
font-weight: 600; font-weight: 600;
padding: 5px; padding: 5px;
color: #000000;
} }
.product-name-display h3 { .product-name-display h3 {

View File

@@ -109,22 +109,23 @@
<h3>Featured Products</h3> <h3>Featured Products</h3>
</div> </div>
</div> </div>
@foreach ($featured_products as $product)
<div <div
class="col-lg-2 col-md-3 col-6" class="col-lg-2 col-md-3 col-6"
v-for="index in 6" v-for="index in 6"
:key="index" :key="index"
> >
<div class="text-center p-3"> <div class="text-center p-3">
<a href="{{ url('store') . '/' . $product->StoreUrl . '/product/' . $product->ProductURL }}">
<div class="store-logo"> <div class="store-logo">
<v-lazy-image <img src="{{ config('site_config.images_url') . '/' . $product->Image }}" alt="{{ $product->ProductName }}" class="d-block border shadow-sm">
src="https://crewsportswear.com/uploads/images/teamstore/all-in-athletics/logo.jpg"
class="d-block border shadow-sm"
alt="..."
/>
</div> </div>
<div class="store-name text-truncate">22PLE</div> <div class="store-name text-truncate">{{ $product->ProductName }}</div>
</a>
</div> </div>
</div> </div>
@endforeach
</div> </div>
</div> </div>
</div> </div>

View File

@@ -365,27 +365,27 @@
<div class="row py-5"> <div class="row py-5">
<div class="col-lg-12"> <div class="col-lg-12">
<h4>Other similar products</h4> <h4>From the same Store</h4>
</div> </div>
<div class="col-md-12"> {{-- <div class="col-md-12">
<p>...</p> <p>...</p>
</div> </div> --}}
{{-- <div @foreach ($store_products as $product)
<div
class="col-lg-2 col-md-3 col-6" class="col-lg-2 col-md-3 col-6"
v-for="index in 6" v-for="index in 6"
:key="index" :key="index"
> >
<div class="text-center p-3"> <div class="text-center p-3">
<a href="{{ url('store') . '/' . $product->StoreUrl . '/product/' . $product->ProductURL }}">
<div class="store-logo"> <div class="store-logo">
<v-lazy-image <img src="{{ config('site_config.images_url') . '/' . $product->Image }}" alt="{{ $product->ProductName }}" class="d-block border shadow-sm">
src="https://crewsportswear.com/uploads/images/teamstore/all-in-athletics/logo.jpg"
class="d-block border shadow-sm"
alt="..."
/>
</div> </div>
<div class="store-name text-truncate">22PLE</div> <div class="store-name text-truncate">{{ $product->ProductName }}</div>
</a>
</div> </div>
</div> --}} </div>
@endforeach
</div> </div>
</div> </div>
</div> </div>