{
"response": {
"first_name": "Кристина",
"last_name": "Шипилова",
"bdate": "20.3.1991",
"bdate_visibility": 2,
"city": {
"id": 21940,
"title": "Верхний Мамон"
},
"country": {
"id": 1,
"title": "Россия"
},
"home_town": "Воронеж В- Мамон",
"maiden_name": "",
"phone": "+7 *** *** ** 79",
"relation": 1,
"sex": 1,
"status": "ОБОЖАЮ СИРЕНЬ😎"
}
}
async asyncData({$axios}) {
let category_items = []
let promise_category = $axios.$get(`${process.env.api}/categories.get`,
{
params: {
lvl: 0,
count: 25,
offset: 0
}
})
.then(({code, count, items}) => {
if (code === 0) {
items.forEach((e) => {
category_items.push({
id: e.id,
name: e.name,
children: [],
deleted_loading: false,
lvl: e.lvl,
selected: false,
})
})
}
})
await Promise.all([promise_category])
return {
category_items
}
},
class ServiceRepository extends NestedTreeRepository
{
...
/**
* @param Service $node
* @return void
* @throws ORMException
* @throws OptimisticLockException
*/
public function removeTree(Service $node)
{
$this->createQueryBuilder("s")
->delete()
->where("s.lft >= :lft")->setParameter("lft", $node->getLft())
->andWhere("s.rgt <= :rgt")->setParameter("rgt", $node->getRgt())
->andWhere("s.root = :root")->setParameter("root", $node->getRoot())
->getQuery()
->execute();
$em = $this->getEntityManager();
$em->beginTransaction();
$repository = $em->getRepository("App:Service");
$refreshLeftAndRight = function($root, $left) use ($repository, &$refreshLeftAndRight) {
$right = $left + 1;
$children = $repository->findBy(['parent' => $root,]);
foreach ($children as $entity) {
$right = $refreshLeftAndRight($entity, $right);
}
$root->setlft($left);
$root->setRgt($right);
return $right + 1;
};
foreach ($repository->findBy(["parent" => null]) as $rootEntry) {
$refreshLeftAndRight($rootEntry, 1);
}
$em->flush();
$em->commit();
}
...
# JsonRequest
App\Service\JsonRequest:
calls:
- [setRequest, ['@request_stack']]
<?php
namespace App\Service;
use Exception;
use Symfony\Component\HttpFoundation\RequestStack;
/**
* Class JsonRequest
* @package App\Service
*/
class JsonRequest
{
private $json_object;
public function __construct()
{
}
/**
* @param string $key
* @param bool $default
* @return mixed
*/
public function get(string $key, $default = null)
{
try {
$properties = explode(".", $key);
$buf = $this->json_object;
foreach ($properties as $property) {
if (property_exists($buf, $property)) {
$buf = $buf->{$property};
} else {
return $default;
}
}
return $buf;
} catch (Exception $e) {
return $default;
}
}
/**
* @param string $key
* @return bool
*/
public function has(string $key)
{
return property_exists($this->json_object, $key);
}
/**
* @param RequestStack $request
*/
public function setRequest(RequestStack $request): void
{
$this->json_object = json_decode($request->getCurrentRequest()->getContent());
}
}
watch: {
search: function(filteredPolis, tipStrah) {
this.filteredPolis.forEach(polis => {
if (polis.tip.indexOf('dmc')) {tipStrah = true}
else if (polis.tip.indexOf('omc')) {tipStrah = false}
return tipStrah
})
console.log(tipStrah)
return tipStrah
}
search(val) {
val // это значение переменой search в data
})
[mysqld]
explicit_defaults_for_timestamp = 1
Как мне нужно изменить код, чтобы v-select занимал не всю ширину контейнера, в котором он находиться, а столько, сколько ему необходимо для отображения своих чисел и чтобы он был выровнен по правому краю.
server {
listen <ip>:<port>;
server_name <ваш домен>;
location / {
proxy_pass http://127.0.0.1:3000;
#proxy_read_timeout 2s
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
}
}
Дальше, получив данные из БД модель выполняет внутренний метод $this->createObject(), который создает из полученных данных из БД объект UserEntity и вставляет в него те поля, которые у нее есть (все остальные указаны по умолчанию в объекте UserEntity). Ну вот собственно и вся ее работа. НО во многих комментариях я вижу сообщения по типу: "модель не должна лезть в БД". Но тогда кто в нее должен лезть?
/**
* @param int $id
* @return mixed
* @throws NonUniqueResultException
* @throws NoResultException
*/
public function getById(int $id) {
return $this->createQueryBuilder("org")
->leftJoin("org.category", "cat")
->leftJoin("org.region", "region")->addSelect("region")
->leftJoin("org.country", "country")->addSelect("country")
->leftJoin("org.city", "city")->addSelect("city")
->leftJoin("org.street", "street")->addSelect("street")
->leftJoin("org.gps", "gps")->addSelect("gps")
->leftJoin("org.services", "services")->addSelect("services")
->leftJoin("services.group", "grp")->addSelect("grp")
->leftJoin("org.images", "images", "", "")->addSelect("images")
->leftJoin("org.reviews", "reviews", Join::WITH, "reviews.status = 1")->addSelect("reviews")
->where("org = :id")->setParameter("id", $id)
->getQuery()
->getSingleResult();
}
/**
* @Rest\Route(
* path="/organization.getById",
* name="organization_get_by_id",
* requirements={ "id"="\d+" }
* )
*
* @param Request $request
* @return object|JsonResponse
* @throws ExceptionInterface
* @throws NonUniqueResultException
* @throws NoResultException
*/
public function getById(Request $request)
{
$organization_repository = $this->getDoctrine()->getManager()->getRepository("App:Organization");
$rs = new ResponseSchemaData();
$rs->setData($organization_repository->getById($request->get("id")));
$serializer = $this->get('serializer');
$response_object = $serializer->normalize($rs, "json", ["attributes" => [
"code",
"data" => [
"id",
"name",
"images",
"description",
"postCode",
"phone",
"email",
"home",
"site",
"schedule",
"images",
"rating",
"gps" => [
"latitude",
"longitude",
],
"category" => [
"id",
"name",
],
"reviews" => [
"id",
"author",
"text",
"likes",
"dislike",
"rating",
"createAt",
],
"services" => [
"id",
"name",
"types" => [
"id",
"name"
]
],
"country" => [
"id",
"name"
],
"region" => [
"id",
"name"
],
"city" => [
"id",
"name"
],
"street" => [
"id",
"name",
"streetType"
],
]
]]);
return new JsonResponse($response_object);
}
{
"data": {
"name": "Здравстолет",
"home": "51",
"phone": "8 (800) 350-29-32",
"site": "https://zdravstolet.ru/",
"schedule": "пн–пт 08:00–17:00",
"id": "641659",
"category": [],
"city": {
"id": 3170,
"name": "Бийск"
},
"street": {
"name": "Петра Мерлина",
"id": 19583,
"street_type": "улица"
},
"country": {
"name": "Россия",
"id": 3159
},
"reviews": [
{
"author": "пиаипиапи",
"text": "иапипиаиапипаипаиапи",
"likes": 0,
"dislike": 0,
"id": "41",
"rating": 0,
"create_at": "2019-09-22T20:03:42+00:00"
}
],
"description": null,
"email": null,
"rating": "3.7",
"services": [],
"images": [],
"post_code": 659303,
"region": null,
"gps": {
"latitude": 52.529974,
"longitude": 85.173845
}
},
"code": 0
}