در حال بارگذاری ...

Using Artisan Commands0:00

Now, we have a Laravel project installed here, so why don't we just search for Laravel and extensions and see what we get. So yes, we have snippets and such, but let's take a look at Laravel Artisan. This allows us to run any of these commands directly from the command palette. Useful. So let's run it, reload, now Shift Command P, Artisan, and there we go. So let's just list all of the routes, and there we go. We can see them inline. And of course, in this case, we only have one. Okay, next, why don't we create a controller?

Creating a Controller0:26

And of course, in this case, we only have one. Okay, next, why don't we create a controller? So I could just say ArtController, and there we go. Or we might be able to get away with just Controller. FooBarController, should it be a resource controller? Sure, and there we go. It creates the file and instantly browses there. So if I hit Shift Command E to go to my sidebar, sure enough, I can see that new file there. So Control Shift G to source control, and we can see this file was added.

Generating Model and Migration0:49

I can see that new file there. So Control Shift G to source control, and we can see this file was added. Great. Maybe we could create a model as well. We'll call it FooBar. Should we have a migration? Yes, no for a controller. So yeah, it will request common options that you might pass. So here's the file, and we should also have a create FooBar table migration. So for example here, we could say table, string, title, whatever.

Configuring SQLite and Migrating1:07

So here's the file, and we should also have a create_foobar_table migration. So for example here, we could say table, string, title, whatever. And then very quickly, let's set the db connection to sqlite, and the name will just be memory for the time being. Okay, so now Shift Command P, migrate, and there we go. And that's all there is to it.

دوست دارید گاهی خبرهای Laracasts را ایمیل کنیم؟