Compare commits
No commits in common. "2651014595697740a7c64736e1425328710c4ccc" and "80a23a5080682a128271995fda2ab6f2bbb2196c" have entirely different histories.
2651014595
...
80a23a5080
@ -31,17 +31,10 @@ function ajax_search()
|
||||
}
|
||||
$result = array();
|
||||
|
||||
$recipes = array();
|
||||
$recipe_models = RecipeModel::filter(
|
||||
$recipes = RecipeModel::filter(
|
||||
count: 5,
|
||||
search: $search_query
|
||||
);
|
||||
foreach ($recipe_models as $recipe_model) {
|
||||
$recipe = $recipe_model->getAssocArr();
|
||||
$recipe['image_url'] = $recipe_model->get_image_url();
|
||||
$recipe['url'] = $recipe_model->get_absolute_url();
|
||||
$recipes[] = $recipe;
|
||||
}
|
||||
|
||||
$result['count'] = count($recipes);
|
||||
$result['result'] = $recipes;
|
||||
@ -139,9 +132,7 @@ function ajax_search_ingredient()
|
||||
search: $search_query
|
||||
);
|
||||
$result['count'] = count($ingredients);
|
||||
$result['result'] = array_map(function($ing) {
|
||||
return $ing->getAssocArr();
|
||||
}, $ingredients);
|
||||
$result['result'] = $ingredients;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -86,10 +86,6 @@ class RecipeModel extends BaseModel
|
||||
);');
|
||||
return $result;
|
||||
}
|
||||
public function get_absolute_url()
|
||||
{
|
||||
return get_permalink('recipes:single', [ $this->get_id() ]);
|
||||
}
|
||||
public function get_price()
|
||||
{
|
||||
return $this->field_estimated_price . '$';
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<a href="<?= $recipe->get_absolute_url() ?>" class="catalog-recipe hover-anim">
|
||||
<a href="<?php the_permalink('recipes:single', [$recipe->get_id()]) ?>" class="catalog-recipe hover-anim">
|
||||
<div class="catalog-recipe__image">
|
||||
<img src="<?= $recipe->get_image_url() ?>" alt="<?= $recipe->field_title ?>">
|
||||
</div>
|
||||
|
||||
@ -364,9 +364,6 @@ abstract class BaseModel
|
||||
else
|
||||
return $filter_result[0]->func_total_count;
|
||||
}
|
||||
public function getAssocArr() {
|
||||
return get_object_vars($this);
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
@ -439,7 +436,7 @@ abstract class BaseModel
|
||||
/**
|
||||
* Return model from Mysql result
|
||||
* @param array $pdo_result pdo resut FETCH_MODE = FETCH_ASSOC
|
||||
* @return array(self)
|
||||
* @return array
|
||||
*/
|
||||
protected static function createObjectsFromQuery(array $pdo_result)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user