from server

This commit is contained in:
root 2023-09-18 11:25:01 +05:00
parent e9b2c4e809
commit 9a0cee0585
7 changed files with 42 additions and 6 deletions

View File

@ -120,7 +120,7 @@ class BlogPostsApiController extends Controller
// }
$currentUser = \JWTAuth::parseToken()->authenticate();
$comment = $this->Comment::where('user_id', $currentUser->id)->paginate(9);
$comment = $this->Comment::where('user_id', $currentUser->id)->with('product')->paginate(9);
//dd($favourite);
return response()->json($comment, 200);
@ -202,6 +202,7 @@ class BlogPostsApiController extends Controller
{
$data = Product::where('vendor_id', $id)
->with('categories:id,name')
->with('vendor')
->with([
'translations:locale,model_id,attribute_data',
'images:attachment_id,attachment_type,disk_name,file_name',
@ -228,7 +229,7 @@ class BlogPostsApiController extends Controller
//$data = User::find($id)->first;
$data = User::where('id', $id)->select('id', 'name', 'email', 'username', 'type', 'logo', 'shop_title', 'slogan', 'work_time', 'description', 'map', 'banner', 'is_instagram')
$data = User::where('id', $id)->select('id', 'name', 'email', 'username', 'type', 'logo', 'shop_title', 'slogan', 'work_time', 'short_description', 'description', 'map', 'banner', 'is_instagram')
->with(['categories' => function($q){
$q->with('translations:locale,model_id,attribute_data');
}])
@ -247,21 +248,21 @@ class BlogPostsApiController extends Controller
{
$data = $request->all();
$dataAccounts = User::select('id', 'name', 'email', 'username', 'type', 'logo', 'shop_title', 'slogan', 'work_time', 'description', 'map', 'banner', 'is_instagram')
$dataAccounts = User::select('id', 'name', 'email', 'username', 'type', 'logo', 'shop_title', 'slogan', 'work_time', 'short_description', 'description', 'map', 'banner', 'is_instagram')
->with('categories:id,name,slug,icon')
->paginate(9);
if($data && $data["type"] == "home"){
$dataAccounts = User::where('is_featured', 1)
->select('id', 'name', 'email', 'username', 'type', 'logo', 'shop_title', 'slogan', 'work_time', 'description', 'map', 'banner', 'is_instagram')
->select('id', 'name', 'email', 'username', 'type', 'logo', 'shop_title', 'slogan', 'work_time', 'short_description', 'description', 'map', 'banner', 'is_instagram')
->with('categories:id,name,slug,icon')
->paginate(9);
}elseif($data && $data["type"] == "category"){
$dataAccounts = User::where('is_category', 1)
->select('id', 'name', 'email', 'username', 'type', 'logo', 'shop_title', 'slogan', 'work_time', 'description', 'map', 'is_instagram')
->select('id', 'name', 'email', 'username', 'type', 'logo', 'shop_title', 'slogan', 'work_time', 'short_description', 'description', 'map', 'is_instagram')
->with('categories:id,name,slug,icon')
->paginate(9);

View File

@ -37,7 +37,7 @@ class MessagesapiController extends Controller
* this is the message_partner with whom
* $currentUser is chatting ('users.id', '!=', $currentUser->id)
*/
$query->select(['users.id', 'username', 'name', 'surname', 'email'])
$query->select(['users.id', 'username', 'name', 'surname', 'email', 'logo', 'banner', 'short_description'])
->where('users.id', '!=', $currentUser->id);
},
'messages' => function ($query) {
@ -53,6 +53,8 @@ class MessagesapiController extends Controller
return $chatroom;
});
$chatrooms[0]->path = 'http://78.111.88.8:9086' . \Config::get('cms.storage.media.path');
// dump(\DB::getQueryLog());
// dd($this->helpers->apiArrayResponseBuilder(200, 'success', ['chatrooms' => $chatrooms]));

View File

@ -63,6 +63,29 @@ class ProductsAPIController extends Controller
->approved()
->orderBy('ends_at', $sortOrder);
if($seller && $categorySeller) {
$category = Category::find($categorySeller);
if($category) {
$query = $category->products()
->with('categories:id,name')
->with([
'translations:locale,model_id,attribute_data',
'images:attachment_id,attachment_type,disk_name,file_name',
])
->withCount(['comments as rating_avg' => function($query) {
$query->select(DB::raw('avg(rating)'));
}])
->where('vendor_id', $seller)
->approved()
->orderBy('ends_at', $sortOrder);
} else {
$query = null;
}
}
if($categoryId) { // fetch offers by the category of the product
$category = Category::find($categoryId);
if($category) {

View File

@ -113,6 +113,12 @@ tabs:
size: huge
type: richeditor
tab: Gurlushyk
short_description:
label: 'Short desc'
span: auto
size: ''
type: textarea
tab: Gurlushyk
categories:
label: Relation
nameFrom: name

View File

@ -21,6 +21,7 @@ class OrderItems extends Model
public $belongsTo = [
'order' => ['TPS\Birzha\Models\Orders', 'table' => 'tps_birzha_orders'],
'product' => ['TPS\Birzha\Models\Product', 'table' => 'tps_birzha_products'],
];
/**

View File

@ -6,6 +6,7 @@ use RainLab\User\Models\User;
use Carbon\Carbon;
use TPS\Birzha\Models\Settings;
use TPS\Birzha\Models\City;
use TPS\Birzha\Models\OrderItems;
/**
* Model
@ -53,6 +54,7 @@ class Product extends Model
public $belongsTo = [
'place' => City::class,
'order_item' => OrderItems::class,
//'measure' => ['TPS\Birzha\Models\Measure','key' => 'measure_id'],
//'currency' => ['TPS\Birzha\Models\Currency'],
//'payment_term' => ['TPS\Birzha\Models\Term','key' => 'payment_term_id'],

View File

@ -0,0 +1 @@
static-pages: { }