@@ -3,8 +3,8 @@ discard block |
||
| 3 | 3 | |
| 4 | 4 | class CreateRightsTable{ |
| 5 | 5 | /** |
| 6 | - * Do the migration |
|
| 7 | - */ |
|
| 6 | + * Do the migration |
|
| 7 | + */ |
|
| 8 | 8 | public function up() |
| 9 | 9 | { |
| 10 | 10 | Capsule::schema()->create('rights', function($table) |
@@ -21,8 +21,8 @@ discard block |
||
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | - * Undo the migration |
|
| 25 | - */ |
|
| 24 | + * Undo the migration |
|
| 25 | + */ |
|
| 26 | 26 | public function down() |
| 27 | 27 | { |
| 28 | 28 | Capsule::schema()->drop('rights'); |
@@ -1,7 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | use Illuminate\Database\Capsule\Manager as Capsule; |
| 3 | 3 | |
| 4 | -class CreateRightsTable{ |
|
| 4 | +class CreateRightsTable { |
|
| 5 | 5 | /** |
| 6 | 6 | * Do the migration |
| 7 | 7 | */ |
@@ -1,14 +1,14 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | use Illuminate\Database\Capsule\Manager as Capsule; |
| 3 | 3 | |
| 4 | -class CreateRightsTable{ |
|
| 4 | +class CreateRightsTable |
|
| 5 | +{ |
|
| 5 | 6 | /** |
| 6 | 7 | * Do the migration |
| 7 | 8 | */ |
| 8 | 9 | public function up() |
| 9 | 10 | { |
| 10 | - Capsule::schema()->create('rights', function($table) |
|
| 11 | - { |
|
| 11 | + Capsule::schema()->create('rights', function($table) { |
|
| 12 | 12 | $table->increments('id'); |
| 13 | 13 | $table->string('name')->unique(); |
| 14 | 14 | $table->string('description'); |
@@ -3,8 +3,8 @@ discard block |
||
| 3 | 3 | |
| 4 | 4 | class CreateUsersTable{ |
| 5 | 5 | /** |
| 6 | - * Do the migration |
|
| 7 | - */ |
|
| 6 | + * Do the migration |
|
| 7 | + */ |
|
| 8 | 8 | public function up() |
| 9 | 9 | { |
| 10 | 10 | Capsule::schema()->create('users', function($table) |
@@ -26,8 +26,8 @@ discard block |
||
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | - * Undo the migration |
|
| 30 | - */ |
|
| 29 | + * Undo the migration |
|
| 30 | + */ |
|
| 31 | 31 | public function down() |
| 32 | 32 | { |
| 33 | 33 | Capsule::schema()->drop('users'); |
@@ -1,7 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | use Illuminate\Database\Capsule\Manager as Capsule; |
| 3 | 3 | |
| 4 | -class CreateUsersTable{ |
|
| 4 | +class CreateUsersTable { |
|
| 5 | 5 | /** |
| 6 | 6 | * Do the migration |
| 7 | 7 | */ |
@@ -1,14 +1,14 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | use Illuminate\Database\Capsule\Manager as Capsule; |
| 3 | 3 | |
| 4 | -class CreateUsersTable{ |
|
| 4 | +class CreateUsersTable |
|
| 5 | +{ |
|
| 5 | 6 | /** |
| 6 | 7 | * Do the migration |
| 7 | 8 | */ |
| 8 | 9 | public function up() |
| 9 | 10 | { |
| 10 | - Capsule::schema()->create('users', function($table) |
|
| 11 | - { |
|
| 11 | + Capsule::schema()->create('users', function($table) { |
|
| 12 | 12 | $table->increments('id'); |
| 13 | 13 | $table->string('email')->unique(); |
| 14 | 14 | $table->string('full_name'); |
@@ -3,8 +3,8 @@ discard block |
||
| 3 | 3 | |
| 4 | 4 | class CreateRolesToRightTable{ |
| 5 | 5 | /** |
| 6 | - * Do the migration |
|
| 7 | - */ |
|
| 6 | + * Do the migration |
|
| 7 | + */ |
|
| 8 | 8 | public function up() |
| 9 | 9 | { |
| 10 | 10 | Capsule::schema()->create('roles_to_rights', function($table) |
@@ -17,8 +17,8 @@ discard block |
||
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | - * Undo the migration |
|
| 21 | - */ |
|
| 20 | + * Undo the migration |
|
| 21 | + */ |
|
| 22 | 22 | public function down() |
| 23 | 23 | { |
| 24 | 24 | Capsule::schema()->drop('roles_to_rights'); |
@@ -1,7 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | use Illuminate\Database\Capsule\Manager as Capsule; |
| 3 | 3 | |
| 4 | -class CreateRolesToRightTable{ |
|
| 4 | +class CreateRolesToRightTable { |
|
| 5 | 5 | /** |
| 6 | 6 | * Do the migration |
| 7 | 7 | */ |
@@ -1,14 +1,14 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | use Illuminate\Database\Capsule\Manager as Capsule; |
| 3 | 3 | |
| 4 | -class CreateRolesToRightTable{ |
|
| 4 | +class CreateRolesToRightTable |
|
| 5 | +{ |
|
| 5 | 6 | /** |
| 6 | 7 | * Do the migration |
| 7 | 8 | */ |
| 8 | 9 | public function up() |
| 9 | 10 | { |
| 10 | - Capsule::schema()->create('roles_to_rights', function($table) |
|
| 11 | - { |
|
| 11 | + Capsule::schema()->create('roles_to_rights', function($table) { |
|
| 12 | 12 | $table->integer('role_id')->unsigned(); |
| 13 | 13 | $table->integer('right_id')->unsigned(); |
| 14 | 14 | $table->primary(['role_id', 'right_id']); |
@@ -2,7 +2,8 @@ |
||
| 2 | 2 | use App\Model\Role; |
| 3 | 3 | use App\Model\User; |
| 4 | 4 | |
| 5 | -class CreateRolesRightsUsers { |
|
| 5 | +class CreateRolesRightsUsers |
|
| 6 | +{ |
|
| 6 | 7 | public function run() |
| 7 | 8 | { |
| 8 | 9 | Role::create([ |
@@ -8,13 +8,13 @@ discard block |
||
| 8 | 8 | // monolog settings |
| 9 | 9 | 'logger' => [ |
| 10 | 10 | 'name' => 'app', |
| 11 | - 'path' => __DIR__ . '/../log/app.log', |
|
| 11 | + 'path' => __DIR__.'/../log/app.log', |
|
| 12 | 12 | ], |
| 13 | 13 | |
| 14 | - 'mailTemplate' => __DIR__ . '/../mail', |
|
| 14 | + 'mailTemplate' => __DIR__.'/../mail', |
|
| 15 | 15 | |
| 16 | 16 | // DB |
| 17 | - 'database' => require(__DIR__ . '/../config/db.php'), |
|
| 17 | + 'database' => require(__DIR__.'/../config/db.php'), |
|
| 18 | 18 | |
| 19 | 19 | // ACL |
| 20 | 20 | 'acl' => |
@@ -50,8 +50,8 @@ discard block |
||
| 50 | 50 | * ['route', ['roles'], ['methods',' methods1']] |
| 51 | 51 | */ |
| 52 | 52 | 'routes' => [ |
| 53 | - ['/api/token', ['guest'], ['post']], |
|
| 54 | - ['/api/user', ['user'], ['get']], |
|
| 53 | + ['/api/token', ['guest'], ['post']], |
|
| 54 | + ['/api/user', ['user'], ['get']], |
|
| 55 | 55 | ], |
| 56 | 56 | /* |
| 57 | 57 | * list of callables to resolve against |
@@ -61,27 +61,27 @@ discard block |
||
| 61 | 61 | * ['callable', ['roles']] |
| 62 | 62 | */ |
| 63 | 63 | 'callables' => [ |
| 64 | - ['App\Controller\CrudController', ['user']], // $app->map(['GET'], '/user', 'App\Controller\UserController'); class with __invoke |
|
| 65 | - ['App\Controller\CrudController:actionIndex', ['user']], // $app->map(['GET'], '/user/{id}', 'App\Controller\UserController:getAction'); class and method |
|
| 66 | - ['App\Controller\CrudController:actionGet', ['user']], |
|
| 67 | - ['App\Controller\CrudController:actionCreate', ['user']], |
|
| 68 | - ['App\Controller\CrudController:actionUpdate', ['user']], |
|
| 69 | - ['App\Controller\CrudController:actionDelete', ['user']], |
|
| 64 | + ['App\Controller\CrudController', ['user']], // $app->map(['GET'], '/user', 'App\Controller\UserController'); class with __invoke |
|
| 65 | + ['App\Controller\CrudController:actionIndex', ['user']], // $app->map(['GET'], '/user/{id}', 'App\Controller\UserController:getAction'); class and method |
|
| 66 | + ['App\Controller\CrudController:actionGet', ['user']], |
|
| 67 | + ['App\Controller\CrudController:actionCreate', ['user']], |
|
| 68 | + ['App\Controller\CrudController:actionUpdate', ['user']], |
|
| 69 | + ['App\Controller\CrudController:actionDelete', ['user']], |
|
| 70 | 70 | |
| 71 | - ['App\Controller\UserController:actionIndex', ['admin']], |
|
| 72 | - ['App\Controller\UserController:actionGet', ['admin']], |
|
| 71 | + ['App\Controller\UserController:actionIndex', ['admin']], |
|
| 72 | + ['App\Controller\UserController:actionGet', ['admin']], |
|
| 73 | 73 | ['App\Controller\UserController:actionCreate', ['admin']], |
| 74 | 74 | ['App\Controller\UserController:actionUpdate', ['admin']], |
| 75 | - ['App\Controller\UserController:actionDelete', ['user']], |
|
| 75 | + ['App\Controller\UserController:actionDelete', ['user']], |
|
| 76 | 76 | ] |
| 77 | 77 | ] |
| 78 | 78 | ], |
| 79 | 79 | |
| 80 | 80 | 'translate' => [ |
| 81 | - 'path' => __DIR__ . '/../lang', |
|
| 81 | + 'path' => __DIR__.'/../lang', |
|
| 82 | 82 | 'locale' => 'ru', |
| 83 | 83 | ], |
| 84 | 84 | |
| 85 | - 'params' => require(__DIR__ . '/../config/params.php'), |
|
| 85 | + 'params' => require(__DIR__.'/../config/params.php'), |
|
| 86 | 86 | ], |
| 87 | 87 | ]; |
@@ -42,12 +42,12 @@ |
||
| 42 | 42 | * |
| 43 | 43 | * @return string |
| 44 | 44 | */ |
| 45 | - public static function generateRandomString($length=32) |
|
| 45 | + public static function generateRandomString($length = 32) |
|
| 46 | 46 | { |
| 47 | 47 | $chars = "abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ023456789"; |
| 48 | 48 | $charsCount = strlen($chars); |
| 49 | 49 | |
| 50 | - srand((double)microtime()*1000000); |
|
| 50 | + srand((double)microtime() * 1000000); |
|
| 51 | 51 | $i = 1; |
| 52 | 52 | $token = ''; |
| 53 | 53 | |
@@ -51,8 +51,7 @@ |
||
| 51 | 51 | $i = 1; |
| 52 | 52 | $token = ''; |
| 53 | 53 | |
| 54 | - while ($i <= $length) |
|
| 55 | - { |
|
| 54 | + while ($i <= $length) { |
|
| 56 | 55 | $num = rand() % $charsCount; |
| 57 | 56 | $tmp = substr($chars, $num, 1); |
| 58 | 57 | $token .= $tmp; |
@@ -49,7 +49,7 @@ |
||
| 49 | 49 | */ |
| 50 | 50 | public static function getUserId() |
| 51 | 51 | { |
| 52 | - if(self::checkUser()){ |
|
| 52 | + if (self::checkUser()) { |
|
| 53 | 53 | return self::$user->id; |
| 54 | 54 | } else { |
| 55 | 55 | return null; |
@@ -8,12 +8,16 @@ discard block |
||
| 8 | 8 | /** |
| 9 | 9 | * Forbidden to create new instances |
| 10 | 10 | */ |
| 11 | - private function __construct() {} |
|
| 11 | + private function __construct() |
|
| 12 | + { |
|
| 13 | +} |
|
| 12 | 14 | |
| 13 | 15 | /** |
| 14 | 16 | * Forbidden to cloned instances |
| 15 | 17 | */ |
| 16 | - private function __clone() {} |
|
| 18 | + private function __clone() |
|
| 19 | + { |
|
| 20 | +} |
|
| 17 | 21 | |
| 18 | 22 | /** |
| 19 | 23 | * @var User |
@@ -49,7 +53,7 @@ discard block |
||
| 49 | 53 | */ |
| 50 | 54 | public static function getUserId() |
| 51 | 55 | { |
| 52 | - if(self::checkUser()){ |
|
| 56 | + if(self::checkUser()) { |
|
| 53 | 57 | return self::$user->id; |
| 54 | 58 | } else { |
| 55 | 59 | return null; |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | public function __construct($templatePath = "", $attributes = []) |
| 23 | 23 | { |
| 24 | - $this->templatePath = rtrim($templatePath, '/\\') . '/'; |
|
| 24 | + $this->templatePath = rtrim($templatePath, '/\\').'/'; |
|
| 25 | 25 | $this->attributes = $attributes; |
| 26 | 26 | } |
| 27 | 27 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | throw new \InvalidArgumentException("Duplicate template key found"); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - if (!is_file($this->templatePath . $template)) { |
|
| 43 | + if (!is_file($this->templatePath.$template)) { |
|
| 44 | 44 | throw new \RuntimeException("View cannot render `$template` because the template does not exist"); |
| 45 | 45 | } |
| 46 | 46 | |
@@ -48,12 +48,12 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | try { |
| 50 | 50 | ob_start(); |
| 51 | - $this->protectedIncludeScope($this->templatePath . $template, $data); |
|
| 51 | + $this->protectedIncludeScope($this->templatePath.$template, $data); |
|
| 52 | 52 | $output = ob_get_clean(); |
| 53 | - } catch(\Throwable $e) { // PHP 7+ |
|
| 53 | + } catch (\Throwable $e) { // PHP 7+ |
|
| 54 | 54 | ob_end_clean(); |
| 55 | 55 | throw $e; |
| 56 | - } catch(\Exception $e) { // PHP < 7 |
|
| 56 | + } catch (\Exception $e) { // PHP < 7 |
|
| 57 | 57 | ob_end_clean(); |
| 58 | 58 | throw $e; |
| 59 | 59 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | * @param string $template |
| 66 | 66 | * @param array $data |
| 67 | 67 | */ |
| 68 | - protected function protectedIncludeScope ($template, array $data) |
|
| 68 | + protected function protectedIncludeScope($template, array $data) |
|
| 69 | 69 | { |
| 70 | 70 | extract($data); |
| 71 | 71 | include $template; |
@@ -50,10 +50,12 @@ |
||
| 50 | 50 | ob_start(); |
| 51 | 51 | $this->protectedIncludeScope($this->templatePath . $template, $data); |
| 52 | 52 | $output = ob_get_clean(); |
| 53 | - } catch(\Throwable $e) { // PHP 7+ |
|
| 53 | + } catch(\Throwable $e) { |
|
| 54 | +// PHP 7+ |
|
| 54 | 55 | ob_end_clean(); |
| 55 | 56 | throw $e; |
| 56 | - } catch(\Exception $e) { // PHP < 7 |
|
| 57 | + } catch(\Exception $e) { |
|
| 58 | +// PHP < 7 |
|
| 57 | 59 | ob_end_clean(); |
| 58 | 60 | throw $e; |
| 59 | 61 | } |
@@ -12,8 +12,8 @@ |
||
| 12 | 12 | |
| 13 | 13 | public function actionIndex() |
| 14 | 14 | { |
| 15 | - echo "This is sample console command." . PHP_EOL; |
|
| 16 | - echo "Actions: " . PHP_EOL; |
|
| 17 | - echo 'partisan sample index' . PHP_EOL; |
|
| 15 | + echo "This is sample console command.".PHP_EOL; |
|
| 16 | + echo "Actions: ".PHP_EOL; |
|
| 17 | + echo 'partisan sample index'.PHP_EOL; |
|
| 18 | 18 | } |
| 19 | 19 | } |
| 20 | 20 | \ No newline at end of file |