Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,540 --> 00:00:04,390
Before we move on, let's talk about CRUD. Do you
2
00:00:04,390 --> 00:00:06,510
know what that acronym stands for?
3
00:00:06,770 --> 00:00:11,380
It stands for create, read, update, and delete.
4
00:00:11,660 --> 00:00:15,550
These are the four basic operations for working with a resource.
5
00:00:15,940 --> 00:00:19,420
In our application, we have a blog post resource, and we
6
00:00:19,420 --> 00:00:22,360
want to allow users to create new posts.
7
00:00:22,740 --> 00:00:27,450
Also, we need to provide a way to read them, in other words,
8
00:00:27,450 --> 00:00:30,420
to show the information about a specific post.
9
00:00:30,690 --> 00:00:34,650
And we also want to allow users to update them and delete them.
10
00:00:35,040 --> 00:00:39,030
This pattern is so common that frameworks like Laravel
11
00:00:39,030 --> 00:00:42,420
provide a lot of functionality to manage these operations
12
00:00:42,430 --> 00:00:45,530
in a predictable and uniform way.
13
00:00:45,650 --> 00:00:46,570
For example,
14
00:00:46,570 --> 00:00:49,790
Laravel provides us with a special type of controller
15
00:00:49,800 --> 00:00:52,260
known as a resource controller.
16
00:00:52,640 --> 00:00:56,400
This resource controller assumes that you will implement
17
00:00:56,410 --> 00:00:59,220
CRUD operations on a specific resource.
18
00:00:59,230 --> 00:01:05,150
So unlike the regular controller, it will be prepopulated with certain actions.
19
00:01:05,540 --> 00:01:11,050
And here are the names of these actions that will be provided by default. Create
20
00:01:11,060 --> 00:01:15,900
and store should sound familiar because that is exactly how we named our two
21
00:01:15,900 --> 00:01:19,600
routes for creating and storing a new post resource.
22
00:01:19,670 --> 00:01:24,940
So the create action should serve a form for creating a new resource, and store
23
00:01:24,940 --> 00:01:29,450
action should actually store that resource in the database.
24
00:01:29,740 --> 00:01:34,620
The show action should read the information from the database about a particular
25
00:01:34,620 --> 00:01:39,730
resource instance and show it to the user. Edit and update are similar to create
26
00:01:39,730 --> 00:01:44,130
and store, but the edit action serves the form for modifying an existing
27
00:01:44,130 --> 00:01:49,280
resource instance and update is used for updating information about that
28
00:01:49,280 --> 00:01:52,780
instance. Destroy is self‑explanatory.
29
00:01:52,790 --> 00:01:56,790
It is used for deleting a specific instance of the resource from the
30
00:01:56,790 --> 00:02:02,500
database. So these actions round up all of the CRUD operations.
31
00:02:02,790 --> 00:02:05,370
This only leaves us with the index section,
32
00:02:05,370 --> 00:02:07,970
which is usually used to present all of the
33
00:02:07,970 --> 00:02:10,560
instances from that specific resource.
34
00:02:10,940 --> 00:02:13,640
So if the resource in question is a blog post,
35
00:02:13,650 --> 00:02:18,860
this action should show a list of all blog posts from the database.
36
00:02:19,240 --> 00:02:20,300
In the next lesson,
37
00:02:20,300 --> 00:02:24,760
we will implement this resource controller in our own application.3299
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.