Commit acf45df788cdcefef45e546a768685fb17ac0b30
1 parent
19f76512
project entity
Showing
2 changed files
with
100 additions
and
1 deletions
Show diff stats
app/library/App/Resources/ProjectResource.php
| ... | ... | @@ -14,7 +14,8 @@ use App\Model\Project; |
| 14 | 14 | use App\Transformers\ProjectTransformer; |
| 15 | 15 | use App\Controllers\ProjectController; |
| 16 | 16 | use App\Constants\AclRoles; |
| 17 | -//use PhalconRest\Mvc\Controllers\CrudResourceController; | |
| 17 | +use PhalconRest\Mvc\Controllers\CrudResourceController; | |
| 18 | + | |
| 18 | 19 | |
| 19 | 20 | |
| 20 | 21 | class ProjectResource extends ApiResource { |
| ... | ... | @@ -27,6 +28,7 @@ class ProjectResource extends ApiResource { |
| 27 | 28 | ->expectsJsonData() |
| 28 | 29 | ->transformer(ProjectTransformer::class) |
| 29 | 30 | ->handler(ProjectController::class) |
| 31 | + ->handler(CrudResourceController::class) | |
| 30 | 32 | ->itemKey('projects') |
| 31 | 33 | ->collectionKey('projects') |
| 32 | 34 | ->allow(AclRoles::AUTHORIZED) | ... | ... |
| 1 | +<?php | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * Created by PhpStorm. | |
| 5 | + * User: Alex Savenko | |
| 6 | + * Date: 07.02.2017 | |
| 7 | + * Time: 12:32 | |
| 8 | + */ | |
| 9 | + | |
| 10 | +use Phalcon\Db\Column as Column; | |
| 11 | +use Phalcon\Db\Index as Index; | |
| 12 | +use Phalcon\Db\Reference as Reference; | |
| 13 | +use Phalcon\Mvc\Model\Migration; | |
| 14 | + | |
| 15 | +class ProductsMigration_100 extends Migration | |
| 16 | +{ | |
| 17 | + public function up() | |
| 18 | + { | |
| 19 | + $this->morphTable( | |
| 20 | + "products", | |
| 21 | + [ | |
| 22 | + "columns" => [ | |
| 23 | + new Column( | |
| 24 | + "id", | |
| 25 | + [ | |
| 26 | + "type" => Column::TYPE_INTEGER, | |
| 27 | + "size" => 10, | |
| 28 | + "unsigned" => true, | |
| 29 | + "notNull" => true, | |
| 30 | + "autoIncrement" => true, | |
| 31 | + "first" => true, | |
| 32 | + ] | |
| 33 | + ), | |
| 34 | + new Column( | |
| 35 | + "product_types_id", | |
| 36 | + [ | |
| 37 | + "type" => Column::TYPE_INTEGER, | |
| 38 | + "size" => 10, | |
| 39 | + "unsigned" => true, | |
| 40 | + "notNull" => true, | |
| 41 | + "after" => "id", | |
| 42 | + ] | |
| 43 | + ), | |
| 44 | + new Column( | |
| 45 | + "name", | |
| 46 | + [ | |
| 47 | + "type" => Column::TYPE_VARCHAR, | |
| 48 | + "size" => 70, | |
| 49 | + "notNull" => true, | |
| 50 | + "after" => "product_types_id", | |
| 51 | + ] | |
| 52 | + ), | |
| 53 | + new Column( | |
| 54 | + "price", | |
| 55 | + [ | |
| 56 | + "type" => Column::TYPE_DECIMAL, | |
| 57 | + "size" => 16, | |
| 58 | + "scale" => 2, | |
| 59 | + "notNull" => true, | |
| 60 | + "after" => "name", | |
| 61 | + ] | |
| 62 | + ), | |
| 63 | + ], | |
| 64 | + "indexes" => [ | |
| 65 | + new Index( | |
| 66 | + "PRIMARY", | |
| 67 | + [ | |
| 68 | + "id", | |
| 69 | + ] | |
| 70 | + ), | |
| 71 | + new Index( | |
| 72 | + "product_types_id", | |
| 73 | + [ | |
| 74 | + "product_types_id", | |
| 75 | + ] | |
| 76 | + ), | |
| 77 | + ], | |
| 78 | + "references" => [ | |
| 79 | + new Reference( | |
| 80 | + "products_ibfk_1", | |
| 81 | + [ | |
| 82 | + "referencedSchema" => "invo", | |
| 83 | + "referencedTable" => "product_types", | |
| 84 | + "columns" => ["product_types_id"], | |
| 85 | + "referencedColumns" => ["id"], | |
| 86 | + ] | |
| 87 | + ), | |
| 88 | + ], | |
| 89 | + "options" => [ | |
| 90 | + "TABLE_TYPE" => "BASE TABLE", | |
| 91 | + "ENGINE" => "InnoDB", | |
| 92 | + "TABLE_COLLATION" => "utf8_general_ci", | |
| 93 | + ], | |
| 94 | + ] | |
| 95 | + ); | |
| 96 | + } | |
| 97 | +} | |
| 0 | 98 | \ No newline at end of file | ... | ... |