Compare commits
No commits in common. "82b4c98f295d3be48c824e642efff261e39bc713" and "ed9cbb1d36839142ae51e4067e5de16425cf17bf" have entirely different histories.
82b4c98f29
...
ed9cbb1d36
@ -1,10 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Lycoreco\Apps\Recipes\Controllers;
|
|
||||||
|
|
||||||
use Lycoreco\Includes\BaseController;
|
|
||||||
|
|
||||||
class CatalogController extends BaseController
|
|
||||||
{
|
|
||||||
protected $template_name = APPS_PATH . '/Recipes/Templates/catalog.php';
|
|
||||||
}
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Lycoreco\Apps\Recipes\Controllers;
|
|
||||||
|
|
||||||
use Lycoreco\Includes\BaseController;
|
|
||||||
|
|
||||||
class SingleRecipeController extends BaseController
|
|
||||||
{
|
|
||||||
protected $template_name = APPS_PATH . '/Recipes/Templates/single.php';
|
|
||||||
}
|
|
||||||
@ -5,20 +5,5 @@ use Lycoreco\Includes\Model\BaseModel;
|
|||||||
|
|
||||||
class CategoryModel extends BaseModel
|
class CategoryModel extends BaseModel
|
||||||
{
|
{
|
||||||
public $field_name;
|
|
||||||
|
|
||||||
static protected $table_name = 'categories';
|
|
||||||
static protected $table_fields = [
|
|
||||||
'id' => 'int',
|
|
||||||
'name' => 'string',
|
|
||||||
];
|
|
||||||
public static function init_table()
|
|
||||||
{
|
|
||||||
$result = db_query('CREATE TABLE ' . static::$table_name . ' (
|
|
||||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
||||||
|
|
||||||
name VARCHAR(255) NOT NULL
|
|
||||||
);');
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -5,29 +5,5 @@ use Lycoreco\Includes\Model\BaseModel;
|
|||||||
|
|
||||||
class IngredientInRecipeModel extends BaseModel
|
class IngredientInRecipeModel extends BaseModel
|
||||||
{
|
{
|
||||||
public $field_ingredient_id;
|
|
||||||
public $field_receipt_id;
|
|
||||||
public $field_amount;
|
|
||||||
|
|
||||||
static protected $table_name = 'recipe_ingredients';
|
|
||||||
static protected $table_fields = [
|
|
||||||
'id' => 'int',
|
|
||||||
'ingredient_id' => 'int',
|
|
||||||
'receipt_id' => 'int',
|
|
||||||
'amount' => 'int'
|
|
||||||
];
|
|
||||||
public static function init_table()
|
|
||||||
{
|
|
||||||
$result = db_query('CREATE TABLE ' . static::$table_name . ' (
|
|
||||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
||||||
|
|
||||||
ingredient_id INT NOT NULL,
|
|
||||||
receipt_id INT NOT NULL,
|
|
||||||
amount INT NOT NULL,
|
|
||||||
|
|
||||||
FOREIGN KEY (ingredient_id) REFERENCES ingredients(id) ON DELETE CASCADE,
|
|
||||||
FOREIGN KEY (receipt_id) REFERENCES recipes(id) ON DELETE CASCADE
|
|
||||||
);');
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -5,23 +5,5 @@ use Lycoreco\Includes\Model\BaseModel;
|
|||||||
|
|
||||||
class IngredientModel extends BaseModel
|
class IngredientModel extends BaseModel
|
||||||
{
|
{
|
||||||
public $field_name;
|
|
||||||
public $field_unit_name;
|
|
||||||
static protected $table_name = 'ingredients';
|
|
||||||
|
|
||||||
static protected $table_fields = [
|
|
||||||
'id' => 'int',
|
|
||||||
'name' => 'string',
|
|
||||||
'unit_name' => 'string'
|
|
||||||
];
|
|
||||||
public static function init_table()
|
|
||||||
{
|
|
||||||
$result = db_query('CREATE TABLE ' . static::$table_name . ' (
|
|
||||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
||||||
|
|
||||||
name VARCHAR(255) NOT NULL,
|
|
||||||
unit_name VARCHAR(20) NULL
|
|
||||||
);');
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -13,33 +13,4 @@ class RecipeModel extends BaseModel
|
|||||||
public $field_author_id;
|
public $field_author_id;
|
||||||
public $field_status;
|
public $field_status;
|
||||||
public $field_created_at;
|
public $field_created_at;
|
||||||
|
|
||||||
static protected $table_name = 'recipes';
|
|
||||||
static protected $table_fields = [
|
|
||||||
'id' => 'int',
|
|
||||||
'title' => 'string',
|
|
||||||
'instruction' => 'string',
|
|
||||||
'estimated_time' => 'int',
|
|
||||||
'estimated_price' => 'int',
|
|
||||||
'author_id' => 'int',
|
|
||||||
'status' => 'string',
|
|
||||||
'created_at' => 'DateTime'
|
|
||||||
];
|
|
||||||
public static function init_table()
|
|
||||||
{
|
|
||||||
$result = db_query('CREATE TABLE ' . static::$table_name . ' (
|
|
||||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
||||||
|
|
||||||
title VARCHAR(255) NOT NULL,
|
|
||||||
instruction TEXT NOT NULL,
|
|
||||||
estimated_time INT NOT NULL,
|
|
||||||
estimated_price INT NOT NULL,
|
|
||||||
author_id INT NOT NULL,
|
|
||||||
status VARCHAR(20) NOT NULL CHECK (status IN (\'publish\', \'pending\')),
|
|
||||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
|
|
||||||
FOREIGN KEY (author_id) REFERENCES users(id) ON DELETE CASCADE
|
|
||||||
);');
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -1 +0,0 @@
|
|||||||
Catalog page
|
|
||||||
@ -1 +0,0 @@
|
|||||||
Single Recipe item
|
|
||||||
@ -1,9 +1,3 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Lycoreco\Apps\Recipes\Controllers;
|
use Lycoreco\Includes\Routing\Path;
|
||||||
use Lycoreco\Includes\Routing\Path;
|
|
||||||
|
|
||||||
$recipes_urls = [
|
|
||||||
new Path('/recipe/[:string]', new Controllers\SingleRecipeController(), 'single'),
|
|
||||||
new Path('/catalog', new Controllers\CatalogController(), 'catalog'),
|
|
||||||
];
|
|
||||||
2
urls.php
2
urls.php
@ -5,13 +5,11 @@ require APPS_PATH . '/Index/urls.php';
|
|||||||
require APPS_PATH . '/Users/urls.php';
|
require APPS_PATH . '/Users/urls.php';
|
||||||
require APPS_PATH . '/Admin/urls.php';
|
require APPS_PATH . '/Admin/urls.php';
|
||||||
require APPS_PATH . '/Ajax/urls.php';
|
require APPS_PATH . '/Ajax/urls.php';
|
||||||
require APPS_PATH . '/Recipes/urls.php';
|
|
||||||
|
|
||||||
Router::includes($index_urls, "index");
|
Router::includes($index_urls, "index");
|
||||||
Router::includes($users_urls, 'users');
|
Router::includes($users_urls, 'users');
|
||||||
Router::includes($admin_urls, 'admin');
|
Router::includes($admin_urls, 'admin');
|
||||||
Router::includes($ajax_urls, 'ajax');
|
Router::includes($ajax_urls, 'ajax');
|
||||||
Router::includes($recipes_urls, 'recipes');
|
|
||||||
|
|
||||||
// Router::set_error_controller('default', new ErrorController())
|
// Router::set_error_controller('default', new ErrorController())
|
||||||
?>
|
?>
|
||||||
Loading…
x
Reference in New Issue
Block a user