la_back/frontend/controllers/OrderController.php

31 lines
757 B
PHP
Raw Normal View History

2023-11-21 19:51:44 +03:00
<?php
namespace frontend\controllers;
use common\models\Order;
/**
* Product controller
*/
class OrderController extends BaseApiController
{
public function actionGetAll()
{
return Order::find()
->where(['user_id' => \Yii::$app->user->id])
->select(['id', 'strength', 'amount', 'table_id'])
->orderBy(['created_at' => SORT_DESC])
->with([
'table' => function (\yii\db\ActiveQuery $query) {
$query->select(['id', 'name']);
},
'products' => function (\yii\db\ActiveQuery $query) {
$query->select(['id', 'taste']);
},
])
->asArray()
->all();
}
}