where($field, $value) ->orderby('Id', 'ASC') ->get(); }else{ $i = DB::table('payment_details') ->leftjoin('orders', 'payment_details.CartKey', '=', 'orders.CartKey') ->leftjoin('teamstores', 'teamstores.Id', '=', 'orders.StoreId') ->select('payment_details.*', 'orders.StoreId', 'teamstores.StoreName') ->where("payment_details.CartKey", "!=", null) ->groupby('orders.CartKey') ->orderby('payment_details.Id', 'ASC') ->get(); } return $i; } function selectOrderItem($field, $ck){ $i = DB::table('orders') ->where($field, $ck) ->get(); return $i; } function itemGroup($cartKey){ $pdo = DB::connection()->getPdo(); $query = $pdo->prepare("SELECT *, COUNT(Id) AS qty, Price * SUM(Quantity) AS total_price FROM orders WHERE CartKey = :ck GROUP BY ProductId"); $query->execute([':ck'=>$cartKey]); $row = $query->fetchAll(\PDO::FETCH_OBJ); return $row; } function selectDisplayItemThumb(){ $i = DB::table('teamstore_product_thumbnails') ->where('ImageClass', 'active') ->get(); return $i; } function selectShippingAddress($field, $value){ $i = DB::table('shipping_addresses') ->where($field, $value) ->get(); return $i; } function selectClientDesign($design_code){ $i = DB::table('client_designs') ->where('DesignCode', $design_code) ->get(); return $i; } function insertTeamstore($data){ $i = DB::table('teamstores')->insert($data); return $i; } function selectTeamstore(){ $i = DB::table('teamstores') ->paginate(16); return $i; } function selectTeamstoreFilter($field, $value){ $i = DB::table('teamstores') ->orderby($field, $value) ->paginate(16); return $i; } function selectTeamstoreSearch($field, $value, $keyword){ $i = DB::table('teamstores') ->where("StoreName", "LIKE","%$keyword%") ->orderby($field, $value) ->paginate(16); return $i; } function selectTeamstoreById($id){ $i = DB::table('teamstores') ->where("Id", $id) ->get(); return $i; } function updateTeamstore($id, $data){ $i = DB::table('teamstores') ->where("Id", $id) ->update($data); return $i; } function deleteTeamstoreById($id){ $i = DB::table('teamstores') ->where("Id", $id) ->delete(); return $i; } function selectPattern(){ $i = DB::table('patterns') ->get(); return $i; } function selectPatternWithfield($field, $value){ $i = DB::table('patterns') ->where($field, $value) ->get(); return $i; } function selectClipartCategory(){ $i = DB::table('clipart_categories') ->leftjoin('user_logins', 'clipart_categories.UserId', '=', 'user_logins.id') ->select('clipart_categories.*', 'user_logins.username') ->orderby('clipart_categories.Ordering', 'ASC') ->get(); return $i; } function ClipartCategory(){ $i = DB::table('clipart_categories') ->leftjoin('user_logins', 'clipart_categories.UserId', '=', 'user_logins.id') ->select('clipart_categories.*', 'user_logins.username') ->orderby('clipart_categories.Ordering', 'ASC') ->paginate(18); return $i; } function selectStoreOwners($store_id){ $i = DB::table('user_logins') ->where('role', 'store_owner') ->where('store_id', $store_id) ->get(); return $i; } function insertClipartCategory($data){ $i = DB::table('clipart_categories')->insertGetId($data); return $i; } function insertClipart($data){ $i = DB::table('cliparts')->insert($data); return $i; } function updateClipartCatOrdering($order, $id){ $i = DB::table('clipart_categories')->where('Id', $id) ->update(['Ordering' => $order]); } function userList(){ $i = DB::table('user_logins') ->select('id', 'name', 'username', 'email') // ->where("name", "LIKE","%$keyword%") // ->orWhere("username", "LIKE","%$keyword%") // ->orWhere("email", "LIKE","%$keyword%") ->where("role", "user") ->orderby('name', 'ASC') ->get(); return $i; } function makeUserAsStoreOwner($data){ $i = DB::table('user_logins') ->where("Id", $data['user_id']) ->update(['role'=> 'store_owner', 'store_id'=> $data['store_id']]); return $i; } function model_removeStoreAccess($data){ $i = DB::table('user_logins') ->where("Id", $data['user_id']) ->update(['role'=> 'user', 'store_id'=> $data['store_id']]); return $i; } function deleteClipartCategory($id){ $i = DB::table('clipart_categories') ->where("Id", $id) ->delete(); return $i; } function updateClipartCategory($id, $data){ $i = DB::table('clipart_categories') ->where("Id", $id) ->update($data); return $i; } function selectCliparts(){ $i = DB::table('cliparts') ->orderby("Id", "DESC") ->paginate(16); return $i; } }