from server
This commit is contained in:
parent
dbaae959a0
commit
e9b2c4e809
|
|
@ -138,7 +138,7 @@ class BlogPostsApiController extends Controller
|
||||||
return $this->helpers->apiArrayResponseBuilder(400, 'fail', $validator->errors() );
|
return $this->helpers->apiArrayResponseBuilder(400, 'fail', $validator->errors() );
|
||||||
}
|
}
|
||||||
|
|
||||||
$comment = $this->Comment::where('product_id', $data["product_id"])->where('is_approve', 1)->paginate(15);
|
$comment = $this->Comment::where('product_id', $data["product_id"])->where('is_approve', 1)->with('user')->paginate(15);
|
||||||
//dd($favourite);
|
//dd($favourite);
|
||||||
|
|
||||||
return response()->json($comment, 200);
|
return response()->json($comment, 200);
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,7 @@ class MessagesapiController extends Controller
|
||||||
return $this->helpers->apiArrayResponseBuilder(404, 'not found', ['error' => 'Resource id=' . $id . ' could not be found']);
|
return $this->helpers->apiArrayResponseBuilder(404, 'not found', ['error' => 'Resource id=' . $id . ' could not be found']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$messages = $chatroom::find($id)->messages()->latest('send_at')->skip($skipParam)->limit(5)->get()->reverse();
|
$messages = $chatroom::find($id)->messages()->latest('send_at')->skip($skipParam)->limit(10)->get();
|
||||||
|
|
||||||
return $this->helpers->apiArrayResponseBuilder(200, 'success', ['messages' => $messages]);
|
return $this->helpers->apiArrayResponseBuilder(200, 'success', ['messages' => $messages]);
|
||||||
}
|
}
|
||||||
|
|
@ -206,7 +206,7 @@ class MessagesapiController extends Controller
|
||||||
|
|
||||||
\Event::fire('tps.message.received', [User::find($newMsg->reciver_id), $currentUser]);
|
\Event::fire('tps.message.received', [User::find($newMsg->reciver_id), $currentUser]);
|
||||||
|
|
||||||
return $this->helpers->apiArrayResponseBuilder(200, 'ok', ['message' => 'message sent successfully']);
|
return $this->helpers->apiArrayResponseBuilder(200, 'ok', ['message' => $newMsg]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -288,7 +288,7 @@ class MessagesapiController extends Controller
|
||||||
->readAtNull()
|
->readAtNull()
|
||||||
->update(['read_at'=>\Carbon\Carbon::now()]);
|
->update(['read_at'=>\Carbon\Carbon::now()]);
|
||||||
|
|
||||||
$messages = $chatroom->messages()->latest('send_at')->limit(5)->get()->reverse();
|
$messages = $chatroom->messages()->latest('send_at')->limit(10)->get();
|
||||||
|
|
||||||
return $messages;
|
return $messages;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ use October\Rain\Support\Facades\Event;
|
||||||
use TPS\Birzha\Classes\ErrorResponseApi;
|
use TPS\Birzha\Classes\ErrorResponseApi;
|
||||||
use TPS\Birzha\Classes\MeasureResource;
|
use TPS\Birzha\Classes\MeasureResource;
|
||||||
use TPS\Birzha\Classes\ProductResource;
|
use TPS\Birzha\Classes\ProductResource;
|
||||||
|
use DB;
|
||||||
|
|
||||||
class ProductsAPIController extends Controller
|
class ProductsAPIController extends Controller
|
||||||
{
|
{
|
||||||
|
|
@ -46,6 +47,9 @@ class ProductsAPIController extends Controller
|
||||||
$queryString = input('q');
|
$queryString = input('q');
|
||||||
$locale = input('locale');
|
$locale = input('locale');
|
||||||
|
|
||||||
|
$seller = input('seller_id');
|
||||||
|
$categorySeller = input('seller_category_id');
|
||||||
|
|
||||||
// $query = $this->Product::with('categories:id,name')
|
// $query = $this->Product::with('categories:id,name')
|
||||||
$query = Product::with([
|
$query = Product::with([
|
||||||
'translations:locale,model_id,attribute_data',
|
'translations:locale,model_id,attribute_data',
|
||||||
|
|
@ -53,6 +57,9 @@ class ProductsAPIController extends Controller
|
||||||
'vendor:id,name,email,type,logo,banner,shop_title,slogan,is_instagram',
|
'vendor:id,name,email,type,logo,banner,shop_title,slogan,is_instagram',
|
||||||
'place',
|
'place',
|
||||||
])
|
])
|
||||||
|
->withCount(['comments as rating_avg' => function($query) {
|
||||||
|
$query->select(DB::raw('avg(rating)'));
|
||||||
|
}])
|
||||||
->approved()
|
->approved()
|
||||||
->orderBy('ends_at', $sortOrder);
|
->orderBy('ends_at', $sortOrder);
|
||||||
|
|
||||||
|
|
@ -65,6 +72,9 @@ class ProductsAPIController extends Controller
|
||||||
'translations:locale,model_id,attribute_data',
|
'translations:locale,model_id,attribute_data',
|
||||||
'images:attachment_id,attachment_type,disk_name,file_name',
|
'images:attachment_id,attachment_type,disk_name,file_name',
|
||||||
])
|
])
|
||||||
|
->withCount(['comments as rating_avg' => function($query) {
|
||||||
|
$query->select(DB::raw('avg(rating)'));
|
||||||
|
}])
|
||||||
->approved()
|
->approved()
|
||||||
->orderBy('ends_at', $sortOrder);
|
->orderBy('ends_at', $sortOrder);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -80,6 +90,9 @@ class ProductsAPIController extends Controller
|
||||||
'place',
|
'place',
|
||||||
'vendor:id,name,email,type,logo,banner,shop_title,slogan,is_instagram'
|
'vendor:id,name,email,type,logo,banner,shop_title,slogan,is_instagram'
|
||||||
])
|
])
|
||||||
|
->withCount(['comments as rating_avg' => function($query) {
|
||||||
|
$query->select(DB::raw('avg(rating)'));
|
||||||
|
}])
|
||||||
->where('is_home', 1)
|
->where('is_home', 1)
|
||||||
->approved()
|
->approved()
|
||||||
->orderBy('ends_at', $sortOrder);
|
->orderBy('ends_at', $sortOrder);
|
||||||
|
|
@ -99,6 +112,9 @@ class ProductsAPIController extends Controller
|
||||||
'translations:locale,model_id,attribute_data',
|
'translations:locale,model_id,attribute_data',
|
||||||
'images:attachment_id,attachment_type,disk_name,file_name',
|
'images:attachment_id,attachment_type,disk_name,file_name',
|
||||||
])
|
])
|
||||||
|
->withCount(['comments as rating_avg' => function($query) {
|
||||||
|
$query->select(DB::raw('avg(rating)'));
|
||||||
|
}])
|
||||||
// ->approvedAndFreshEndDate()
|
// ->approvedAndFreshEndDate()
|
||||||
->approved()
|
->approved()
|
||||||
->orderBy('ends_at', $sortOrder);
|
->orderBy('ends_at', $sortOrder);
|
||||||
|
|
@ -113,6 +129,9 @@ class ProductsAPIController extends Controller
|
||||||
'translations:locale,model_id,attribute_data',
|
'translations:locale,model_id,attribute_data',
|
||||||
'images:attachment_id,attachment_type,disk_name,file_name',
|
'images:attachment_id,attachment_type,disk_name,file_name',
|
||||||
])
|
])
|
||||||
|
->withCount(['comments as rating_avg' => function($query) {
|
||||||
|
$query->select(DB::raw('avg(rating)'));
|
||||||
|
}])
|
||||||
->orderBy('ends_at', $sortOrder);
|
->orderBy('ends_at', $sortOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -136,13 +155,14 @@ class ProductsAPIController extends Controller
|
||||||
'vendor:id,name,surname,email,username,logo,banner',
|
'vendor:id,name,surname,email,username,logo,banner',
|
||||||
'files', 'place',
|
'files', 'place',
|
||||||
])
|
])
|
||||||
->withCount('comments')->withAvg('comments', 'rating')
|
//->withCount('comments')->withAvg('comments', 'rating')
|
||||||
// ->withCount(['comments as comments_avg_votes' => function($query) {
|
->withCount(['comments as rating_avg' => function($query) {
|
||||||
// $query->select(DB::raw('avg(rating)'));
|
$query->select(DB::raw('avg(rating)'));
|
||||||
// }])
|
}])
|
||||||
->find($id);
|
->find($id);
|
||||||
|
|
||||||
$data->main_path = 'http://78.111.88.8:9086' . \Config::get('cms.storage.media.path');
|
$data->main_path = 'http://78.111.88.8:9086' . \Config::get('cms.storage.media.path');
|
||||||
|
//$data->rating_avg = number_format((float)$data->rating_avg, 1, '.', '');;
|
||||||
|
|
||||||
if ($data && $data->status == 'approved' /*&& $data->ends_at >= \Carbon\Carbon::now()*/){
|
if ($data && $data->status == 'approved' /*&& $data->ends_at >= \Carbon\Carbon::now()*/){
|
||||||
return response()->json($data, 200);
|
return response()->json($data, 200);
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ class User extends UserBase
|
||||||
'sliders' => ['TPS\Birzha\Models\UserSliders', 'softDelete' => true],
|
'sliders' => ['TPS\Birzha\Models\UserSliders', 'softDelete' => true],
|
||||||
'favourites' => ['TPS\Birzha\Models\Favourites', 'softDelete' => true, 'table' => 'tps_birzha_favourites'],
|
'favourites' => ['TPS\Birzha\Models\Favourites', 'softDelete' => true, 'table' => 'tps_birzha_favourites'],
|
||||||
'comments' => ['TPS\Birzha\Models\Comment','table' => 'tps_birzha_comments'],
|
'comments' => ['TPS\Birzha\Models\Comment','table' => 'tps_birzha_comments'],
|
||||||
|
'orders' => ['TPS\Birzha\Models\Orders','table' => 'tps_birzha_orders'],
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -109,9 +109,9 @@ tabs:
|
||||||
tab: Gurlushyk
|
tab: Gurlushyk
|
||||||
description:
|
description:
|
||||||
label: Maglumat
|
label: Maglumat
|
||||||
size: ''
|
|
||||||
span: auto
|
span: auto
|
||||||
type: textarea
|
size: huge
|
||||||
|
type: richeditor
|
||||||
tab: Gurlushyk
|
tab: Gurlushyk
|
||||||
categories:
|
categories:
|
||||||
label: Relation
|
label: Relation
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php namespace TPS\Birzha\Models;
|
||||||
|
|
||||||
|
use Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model
|
||||||
|
*/
|
||||||
|
class OrderItems extends Model
|
||||||
|
{
|
||||||
|
use \October\Rain\Database\Traits\Validation;
|
||||||
|
|
||||||
|
use \October\Rain\Database\Traits\SoftDelete;
|
||||||
|
|
||||||
|
protected $dates = ['deleted_at'];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string The database table used by the model.
|
||||||
|
*/
|
||||||
|
public $table = 'tps_birzha_order_items';
|
||||||
|
|
||||||
|
public $belongsTo = [
|
||||||
|
'order' => ['TPS\Birzha\Models\Orders', 'table' => 'tps_birzha_orders'],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array Validation rules
|
||||||
|
*/
|
||||||
|
public $rules = [
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php namespace TPS\Birzha\Models;
|
||||||
|
|
||||||
|
use Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model
|
||||||
|
*/
|
||||||
|
class Orders extends Model
|
||||||
|
{
|
||||||
|
use \October\Rain\Database\Traits\Validation;
|
||||||
|
|
||||||
|
use \October\Rain\Database\Traits\SoftDelete;
|
||||||
|
|
||||||
|
protected $dates = ['deleted_at'];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string The database table used by the model.
|
||||||
|
*/
|
||||||
|
public $table = 'tps_birzha_orders';
|
||||||
|
|
||||||
|
public $belongsTo = [
|
||||||
|
'user' => ['RainLab\User\Models\User', 'table' => 'users'],
|
||||||
|
];
|
||||||
|
|
||||||
|
public $hasMany = [
|
||||||
|
'order_items' => ['TPS\Birzha\Models\OrderItems', 'key' => 'order_id', 'softDelete' => true],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array Validation rules
|
||||||
|
*/
|
||||||
|
public $rules = [
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
columns:
|
||||||
|
id:
|
||||||
|
label: id
|
||||||
|
type: number
|
||||||
|
items:
|
||||||
|
label: items
|
||||||
|
type: text
|
||||||
|
note:
|
||||||
|
label: note
|
||||||
|
type: text
|
||||||
|
created_at:
|
||||||
|
label: created_at
|
||||||
|
type: datetime
|
||||||
|
order_id:
|
||||||
|
label: order_id
|
||||||
|
type: number
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
fields:
|
||||||
|
note:
|
||||||
|
label: Note
|
||||||
|
span: auto
|
||||||
|
type: textarea
|
||||||
|
items:
|
||||||
|
label: Items
|
||||||
|
span: auto
|
||||||
|
type: repeater
|
||||||
|
form:
|
||||||
|
fields:
|
||||||
|
product_id:
|
||||||
|
label: Product
|
||||||
|
span: auto
|
||||||
|
type: number
|
||||||
|
qty:
|
||||||
|
label: Quantity
|
||||||
|
span: auto
|
||||||
|
type: number
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
columns:
|
||||||
|
id:
|
||||||
|
label: id
|
||||||
|
type: number
|
||||||
|
created_at:
|
||||||
|
label: created_at
|
||||||
|
type: datetime
|
||||||
|
user_id:
|
||||||
|
label: user_id
|
||||||
|
type: number
|
||||||
|
note:
|
||||||
|
label: note
|
||||||
|
type: text
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
fields:
|
||||||
|
user:
|
||||||
|
label: 'User id'
|
||||||
|
span: auto
|
||||||
|
nameFrom: name
|
||||||
|
descriptionFrom: description
|
||||||
|
type: relation
|
||||||
|
note:
|
||||||
|
label: Note
|
||||||
|
span: auto
|
||||||
|
type: textarea
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
<?php namespace TPS\Birzha\Updates;
|
||||||
|
|
||||||
|
use Schema;
|
||||||
|
use October\Rain\Database\Updates\Migration;
|
||||||
|
|
||||||
|
class BuilderTableCreateTpsBirzhaOrderItems extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('tps_birzha_order_items', function($table)
|
||||||
|
{
|
||||||
|
$table->engine = 'InnoDB';
|
||||||
|
$table->increments('id')->unsigned();
|
||||||
|
$table->timestamp('created_at')->nullable();
|
||||||
|
$table->timestamp('updated_at')->nullable();
|
||||||
|
$table->timestamp('deleted_at')->nullable();
|
||||||
|
$table->text('items');
|
||||||
|
$table->text('note');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('tps_birzha_order_items');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
<?php namespace TPS\Birzha\Updates;
|
||||||
|
|
||||||
|
use Schema;
|
||||||
|
use October\Rain\Database\Updates\Migration;
|
||||||
|
|
||||||
|
class BuilderTableCreateTpsBirzhaOrders extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('tps_birzha_orders', function($table)
|
||||||
|
{
|
||||||
|
$table->engine = 'InnoDB';
|
||||||
|
$table->increments('id')->unsigned();
|
||||||
|
$table->timestamp('created_at')->nullable();
|
||||||
|
$table->timestamp('updated_at')->nullable();
|
||||||
|
$table->timestamp('deleted_at')->nullable();
|
||||||
|
$table->integer('user_id');
|
||||||
|
$table->text('note');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('tps_birzha_orders');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php namespace TPS\Birzha\Updates;
|
||||||
|
|
||||||
|
use Schema;
|
||||||
|
use October\Rain\Database\Updates\Migration;
|
||||||
|
|
||||||
|
class BuilderTableUpdateTpsBirzhaOrderItems extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('tps_birzha_order_items', function($table)
|
||||||
|
{
|
||||||
|
$table->integer('order_id');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('tps_birzha_order_items', function($table)
|
||||||
|
{
|
||||||
|
$table->dropColumn('order_id');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -395,3 +395,12 @@
|
||||||
1.0.138:
|
1.0.138:
|
||||||
- 'Created table tps_birzha_notifications'
|
- 'Created table tps_birzha_notifications'
|
||||||
- builder_table_create_tps_birzha_notifications.php
|
- builder_table_create_tps_birzha_notifications.php
|
||||||
|
1.0.139:
|
||||||
|
- 'Created table tps_birzha_orders'
|
||||||
|
- builder_table_create_tps_birzha_orders.php
|
||||||
|
1.0.140:
|
||||||
|
- 'Created table tps_birzha_order_items'
|
||||||
|
- builder_table_create_tps_birzha_order_items.php
|
||||||
|
1.0.141:
|
||||||
|
- 'Updated table tps_birzha_order_items'
|
||||||
|
- builder_table_update_tps_birzha_order_items.php
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,8 @@ Route::group(['prefix' => 'api'], function() {
|
||||||
Route::get('me', function() {
|
Route::get('me', function() {
|
||||||
|
|
||||||
$me = \JWTAuth::parseToken()->authenticate()
|
$me = \JWTAuth::parseToken()->authenticate()
|
||||||
->only(['name','surname','email','username','type', 'logo', 'banner', 'shop_title', 'slogan', 'is_instagram']);
|
->only(['id','name','surname','email','username','type', 'logo', 'banner', 'shop_title', 'slogan', 'is_instagram']);
|
||||||
|
$user["path"] = 'http://78.111.88.8:9086' . \Config::get('cms.storage.media.path');
|
||||||
|
|
||||||
return Response::json(compact('me'));
|
return Response::json(compact('me'));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue