How to migrate the file Model (base ORM)



General 1 year ago by szymkiw

Hello,

I write the file Model in the fiels : Models and i create a file of migration with this command : php forge make:migrate.

But i want to migrate the model file but there aren't command, only for database : php forge migrate : this command migrate the file in Database/Migrations. But not in Models. How can i do it ?

Thank you for your answer



1 year ago by daveismyname

you can do

php forge module:migrate

To run migrations for modules.



1 year ago by szymkiw

This command will migrate all modul and no Models in the App\Models



1 year ago by daveismyname

Oh I think I mis-understood what you ment.

You cannot migrate the models only migrations to use the models is a case of impoting them into your controller and calling the model ie

Import:

use App\Models\User;

use it:

$user = User::all();


1 year ago by szymkiw

okay i undertsand :)

Thank you, i thought that i can use like Symfony whith manytoMany, etc...

Thank you



1 year ago by daveismyname

Yes you can you would define your relationships within your model, please read through https://novaframework.com/documentation/v3/database-orm#relationships



1 year ago by szymkiw

okay, i read very fast sorry thank you



1 year ago by szymkiw

and to run the propertry what is the command ?



1 year ago by daveismyname

you refer to your model so say you have a relationship called user on a model of post you can do:

$posts = Post::all();
foreach($posts as $post){
   echo $post->user->username;
}


1 year ago by szymkiw

okay thank you very much


Login to reply.