Can make:controller command create nested controller class? - laravel-5.4

I am using laravel 5.4 to develop a project. I have a question about php artisan make:controller command. Can this command create a nested controller class, like app/Http/Controllers/Admin/PostController this? Or to do this I need to manually create this controller?

You can create create controllers in any controller namespace with the artisan command php artisan make:controller Admin/ControllerName
You can also create a resource controller by adding the --resource flag to the command.
You can go even further and typehint the model you wish to use with the controller by adding the --model=ModelName flag to the artisan command. If the model you have suggested does not exist, artisan will ask you if you would like to create this model.

Related

Could not open input file: yii when i start rbac migration

I'm new on mac, I'm trying to make migration for rbac, but i have error
Could not open input file: yii
I read a lot of answers and tried everything, but nothing suits me
what could be the problem?
as your ls statement shows, there's no yii file. (yii.bat doesn't count)
you need to run the init script again to generate it
php init

Yii2 run only specific migration

In Yii2, when I use the
yii migrate
command, I get a long list of remaining migrations. How can I only run one specific migration in the list without performing the others?
Run migrate/history to list migrations have been applied:
./yii migrate/history
Copy the name of migration you want to return to later (lets say it is 'm160101_185401_initial_migration'). Save it somewhere because you're going to need this later.
Mark migration history at the one just before the one you need to run:
./yii migrate/mark m170101_185401_create_news_table
Run one migration:
./yii migrate 1
Reset migration history:
./yii migrate/mark m160101_185401_initial_migration
yii migrate --migrationPath=#app/modules/forum/
If you want to skip some migrations that have been implemented in your database without running the migrations, you set your migrations state without running them.
By "marking" the migrations you also assure they will no longer be re-prompted and will be regarded as "done".
you can read about marking in the Yii docs here
To run specific migration, you can mark(skip) migrations upto just before one you want run.
You can mark migration by using one of following command:
Using timestamp to specify the migration yii migrate/mark 150101_185401
Using a string that can be parsed by strtotime() yii migrate/mark "2015-01-01 18:54:01"
Using full nameyii migrate/mark m150101_185401_create_news_table
Using UNIX timestamp yii migrate/mark 1392853618

The #isset directive is not been rendered by Laravel 5.4

I'm developing a blade view on Laravel 5.4 which tests if a variable is set. If it is not set, the blade must present a little piece of html code placed into it. The problem is Laravel ignores or doesn't recognize the #isset directive rendering the string as if it was a simple html code. See the picture:
I have done a ugly workaround using #if(! empty($test) ). And I already tried to clean the cache with php artisan cache:clear.
Did someone know something that can cause this problem? Thanks a lot!
I solved my problem updating Laravel Framework from 5.4.15 to 5.4.36.
First, stop your server (if you are using php artisan serve).
Then run composer update on root directory of the project.
Probably you need to run php artisan cache:clear before serve the project again, in my case it wasn't necessary.
It's a strange behavior of Laravel witch probably is a little bug on Laravel Framework 5.4.15 or earlier.

What is the command to generate migration script from existing sequelize models?

I've created models using the following command.
$ node_modules/.bin/sequelize model:create --name XYZ --attributes "....."
But by mistake I deleted the folder containing migration script. Now I want to generate this script again.
I tried using sequelize migration:create, but it generated any empty file.
Please Help.
What you need to do now, after you generated a new migration file is to copy the skeleton from here: http://docs.sequelizejs.com/manual/tutorial/migrations.html#skeleton and to customize your migration using the functions that you need.

Include additional library to yii2

There is yii2 which instaled via composer. What specific steps should be taken to connect the additional library library to the current project. Also same question if need connect only simple class.
Composer found at https://getcomposer.org is your best friend while adding new libraries to yii2 framework.
e.g. you would like to add kartik yii2 widgets found at http://demos.krajee.com/ to your yii2 application.
for that you need to have php installed in your development machine and have it accessible via command line.
e.g. execute following command from command line to check php version.
php -v
if it works then fine, if not, that you need to set path variable.
download composer.phar from https://getcomposer.org
copy composer.phar to that directory.
go to yii2 application folder using CD through command prompt
execute following command from command line
php composer.phar require kartik-v/yii2-widgets "*"
Now sit and watch it kartik extensions of yii2 will be installed.
To simply connect and using any custom class, follow this guide.
http://www.yiiframework.com/wiki/747/write-use-a-custom-component-in-yii2-0/
Yii is mvc framework and it has specific methodology to connect and use with model, view, conntroller.
Follow this link to find more
http://www.yiiframework.com/doc/guide/1.1/en/basics.mvc
Normally additional libraries (extensions) are provided with commands for installing the necessary software by composer and instructions on how to configure these modules and components in this initial configuration file. In the advanced template (the organizing schema of the most appropriate code for professional projects) is called main.php and is located in the config directory of each appllicazione (frontend, backend) and in common area accessible to entering for shared configurations. .
For what regards the addition of classes .. all what is related to the MVC programming pattern is well organized in the appropriate directory, and then the addition of application classes favors this scheme ..
The management of classes or related items can be organized easily into components and modules .........
For all of these and much more you can refer to the guide that is also able to illustrate with concrete examples the many features that characterize Yii.
http://www.yiiframework.com/doc-2.0/guide-index.html
http://www.yiiframework.com/doc-2.0/