from server

This commit is contained in:
root 2023-07-27 22:50:18 +05:00
parent 77c27f4b5f
commit 5a985dc5dd
7 changed files with 55 additions and 80 deletions

View File

@ -11,6 +11,7 @@ use Illuminate\Support\Facades\Validator;
use RainLab\Blog\Models\Post; use RainLab\Blog\Models\Post;
use TPS\Birzha\Classes\BlogPostResource; use TPS\Birzha\Classes\BlogPostResource;
use TPS\Birzha\Models\SliderApp; use TPS\Birzha\Models\SliderApp;
use RainLab\User\Models\User;
class BlogPostsApiController extends Controller class BlogPostsApiController extends Controller
{ {
@ -44,6 +45,28 @@ class BlogPostsApiController extends Controller
->paginate($data['per_page'] ?? 7))->response()->getData(), 200); ->paginate($data['per_page'] ?? 7))->response()->getData(), 200);
} }
public function getAccounts(Request $request)
{
//$path = Config::get('cms.storage.media.path');
$dataAccounts = User::where('is_featured', 1)
->select('id', 'name', 'email', 'username', 'type', 'logo', 'shop_title', 'slogan', 'work_time', 'description', 'map')
->get();
//$dataSlider["img"] = $path.$dataSlider["img"];
if($dataAccounts){
$dataAccounts->each(function ($item, $key) {
$item->logo = 'http://78.111.88.8:9086'.Config::get('cms.storage.media.path').$item->logo;
});
}
return response()->json($dataAccounts, 200);
}
public function getSliders(Request $request) public function getSliders(Request $request)
{ {
$path = Config::get('cms.storage.media.path'); $path = Config::get('cms.storage.media.path');

View File

@ -47,8 +47,8 @@ class ProductsAPIController extends Controller
$query = $this->Product::with([ $query = $this->Product::with([
'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',
'measure.translations:locale,model_id,attribute_data', //'measure.translations:locale,model_id,attribute_data',
'currency.translations:locale,model_id,attribute_data' //'currency.translations:locale,model_id,attribute_data'
]) ])
// ->approvedAndFreshEndDate() // ->approvedAndFreshEndDate()
->approved() ->approved()
@ -62,8 +62,8 @@ class ProductsAPIController extends Controller
->with([ ->with([
'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',
'measure.translations:locale,model_id,attribute_data', //'measure.translations:locale,model_id,attribute_data',
'currency.translations:locale,model_id,attribute_data' //'currency.translations:locale,model_id,attribute_data'
]) ])
// ->approvedAndFreshEndDate() // ->approvedAndFreshEndDate()
->approved() ->approved()
@ -86,8 +86,8 @@ class ProductsAPIController extends Controller
->with([ ->with([
'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',
'measure.translations:locale,model_id,attribute_data', //'measure.translations:locale,model_id,attribute_data',
'currency.translations:locale,model_id,attribute_data' //'currency.translations:locale,model_id,attribute_data'
]) ])
// ->approvedAndFreshEndDate() // ->approvedAndFreshEndDate()
->approved() ->approved()
@ -102,18 +102,18 @@ class ProductsAPIController extends Controller
->with([ ->with([
'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',
'measure.translations:locale,model_id,attribute_data', //'measure.translations:locale,model_id,attribute_data',
'currency.translations:locale,model_id,attribute_data' //'currency.translations:locale,model_id,attribute_data'
]) ])
->orderBy('ends_at', $sortOrder); ->orderBy('ends_at', $sortOrder);
} }
$data = $query ? $query->paginate($perPage) : null; $data = $query ? $query->paginate($perPage) : null;
if($data) { //if($data) {
foreach ($data as $product) { // foreach ($data as $product) {
$product->unit = new MeasureResource($product->measure); // $product->unit = new MeasureResource($product->measure);
} // }
} // }
// if($data) { // if($data) {
// $data->each(function ($item, $key) { // $data->each(function ($item, $key) {

View File

@ -28,6 +28,7 @@ Route::group(['prefix' =>'api/v1','namespace' =>'AhmadFatoni\ApiGenerator\Contro
Route::get('news/{id}', 'BlogPostsApiController@show')->where(['id' => '[0-9]+']); Route::get('news/{id}', 'BlogPostsApiController@show')->where(['id' => '[0-9]+']);
Route::get('sliders', 'BlogPostsApiController@getSliders'); Route::get('sliders', 'BlogPostsApiController@getSliders');
Route::get('accounts', 'BlogPostsApiController@getAccounts');
Route::middleware(['\Tymon\JWTAuth\Middleware\GetUserFromToken'])->group(function () { Route::middleware(['\Tymon\JWTAuth\Middleware\GetUserFromToken'])->group(function () {

View File

@ -126,6 +126,12 @@ tabs:
span: auto span: auto
type: textarea type: textarea
tab: Gurlushyk tab: Gurlushyk
is_featured:
label: 'Bash Sahypa'
span: auto
disabled: 0
type: switch
tab: Gurlushyk
categories: categories:
label: Relation label: Relation
nameFrom: name nameFrom: name

View File

@ -35,9 +35,9 @@ class Product extends Model
'slug' => 'required', 'slug' => 'required',
'images' => 'required', 'images' => 'required',
'quantity' => 'required', 'quantity' => 'required',
'measure' => 'required', //'measure' => 'required',
'price' => 'required|numeric|max:9999999', 'price' => 'required|numeric|max:9999999',
'currency' => 'required', //'currency' => 'required',
]; ];
public $customMessages = [ public $customMessages = [
@ -50,10 +50,10 @@ class Product extends Model
public $belongsTo = [ public $belongsTo = [
// 'country' => ['TPS\Birzha\Models\Country'], // 'country' => ['TPS\Birzha\Models\Country'],
'measure' => ['TPS\Birzha\Models\Measure','key' => 'measure_id'], //'measure' => ['TPS\Birzha\Models\Measure','key' => 'measure_id'],
'currency' => ['TPS\Birzha\Models\Currency'], //'currency' => ['TPS\Birzha\Models\Currency'],
'payment_term' => ['TPS\Birzha\Models\Term','key' => 'payment_term_id'], //'payment_term' => ['TPS\Birzha\Models\Term','key' => 'payment_term_id'],
'delivery_term' => ['TPS\Birzha\Models\Term','key' => 'delivery_term_id'], //'delivery_term' => ['TPS\Birzha\Models\Term','key' => 'delivery_term_id'],
'vendor' => User::class, 'vendor' => User::class,
'payment' => ['TPS\Birzha\Models\Payment'], 'payment' => ['TPS\Birzha\Models\Payment'],
]; ];

View File

@ -7,13 +7,11 @@ columns:
label: Name label: Name
type: text type: text
searchable: true searchable: true
sortable:
user_id: user_id:
label: User label: User
type: vendor type: vendor
relation: vendor relation: vendor
sortable: false valueFrom: username
valueFrom: email
status: status:
label: Status label: Status
type: status type: status

View File

@ -22,14 +22,6 @@ fields:
span: auto span: auto
readOnly: 1 readOnly: 1
type: datepicker type: datepicker
manufacturer:
label: Manufacturer
span: auto
type: text
country:
label: 'Manufacturer country'
span: auto
type: text
quantity: quantity:
label: Quantity label: Quantity
span: auto span: auto
@ -39,12 +31,6 @@ fields:
mode: datetime mode: datetime
span: auto span: auto
type: datepicker type: datepicker
measure:
label: Measure
nameFrom: name
descriptionFrom: description
span: auto
type: relation
price: price:
label: Price label: Price
span: auto span: auto
@ -55,26 +41,6 @@ fields:
mode: tab mode: tab
span: auto span: auto
type: text type: text
currency:
label: Currency
nameFrom: name
descriptionFrom: description
span: auto
type: relation
payment_term:
label: 'Payment term'
nameFrom: name
descriptionFrom: description
scope: payment
span: auto
type: relation
delivery_term:
label: 'Delivery term'
nameFrom: name
descriptionFrom: description
scope: delivery
span: auto
type: relation
place: place:
label: Place label: Place
span: auto span: auto
@ -85,11 +51,6 @@ fields:
descriptionFrom: description descriptionFrom: description
span: auto span: auto
type: relation type: relation
payed_fee_for_publ:
label: 'Payed for publication'
span: auto
disabled: 1
type: number
images: images:
label: Images label: Images
mode: image mode: image
@ -101,20 +62,6 @@ fields:
extension: auto extension: auto
span: auto span: auto
type: fileupload type: fileupload
packaging:
label: Packaging
options:
'no': 'no'
'yes': 'yes'
span: auto
type: balloon-selector
market_type:
label: 'Market type'
options:
in: in
out: out
span: left
type: balloon-selector
tabs: tabs:
fields: fields:
categories: categories:
@ -129,11 +76,11 @@ tabs:
status: status:
label: Status label: Status
options: options:
draft: Draft draft: Pozulan
new: New new: Taze
approved: Approved approved: Tassyklandy
denied: Denied denied: 'Otkaz Edildi'
disabled: Disabled disabled: 'Wagtlayyn Ochurmek'
span: auto span: auto
required: 1 required: 1
type: balloon-selector type: balloon-selector