Compare commits
No commits in common. "cc0125d9978b8003bce549199e35bd976eed6e55" and "aa0e153f6517ff22ba98a21852a2318c2936ea4e" have entirely different histories.
cc0125d997
...
aa0e153f65
@ -16,7 +16,6 @@ class RecipeModel extends BaseModel
|
|||||||
public $field_created_at;
|
public $field_created_at;
|
||||||
|
|
||||||
public $category_name;
|
public $category_name;
|
||||||
public $is_in_favorite = 0;
|
|
||||||
|
|
||||||
const STATUS = [['publish', 'Publish'], ['pending', 'Pending']];
|
const STATUS = [['publish', 'Publish'], ['pending', 'Pending']];
|
||||||
|
|
||||||
@ -49,23 +48,6 @@ class RecipeModel extends BaseModel
|
|||||||
'status' => 'string',
|
'status' => 'string',
|
||||||
'created_at' => 'DateTime'
|
'created_at' => 'DateTime'
|
||||||
];
|
];
|
||||||
protected static function get_additional_fields(){
|
|
||||||
$add_fields = parent::get_additional_fields();
|
|
||||||
|
|
||||||
// If user is authorized, we also check product in thw wishlist
|
|
||||||
if(CURRENT_USER) {
|
|
||||||
$add_fields = array_merge($add_fields, array(
|
|
||||||
[
|
|
||||||
"field" => [
|
|
||||||
"MAX(CASE WHEN fav.user_id = ". CURRENT_USER->get_id() ." THEN 1 ELSE 0 END) AS is_in_favorite"
|
|
||||||
],
|
|
||||||
"join_table" => "recipe_favorites fav ON fav.recipe_id = obj.id"
|
|
||||||
]
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
return $add_fields;
|
|
||||||
}
|
|
||||||
public static function init_table()
|
public static function init_table()
|
||||||
{
|
{
|
||||||
$result = db_query('CREATE TABLE ' . static::$table_name . ' (
|
$result = db_query('CREATE TABLE ' . static::$table_name . ' (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user