initial commit
This commit is contained in:
187
app/Models/admin/AdminModel.php
Normal file
187
app/Models/admin/AdminModel.php
Normal file
@@ -0,0 +1,187 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\admin;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use DB;
|
||||
|
||||
class AdminModel extends Model
|
||||
{
|
||||
function selectPaymentDetails($field, $value){
|
||||
|
||||
if($field != "All"){
|
||||
$i = DB::table('payment_details')
|
||||
->where($field, $value)
|
||||
->orderby('Id', 'ASC')
|
||||
->get();
|
||||
}else{
|
||||
|
||||
$i = DB::table('payment_details')
|
||||
->orderby('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 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')->insert($data);
|
||||
return $i;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user