Skip to content

Commit 3aa5aba

Browse files
authored
Fix typos and make minor edits
Fix typos and make minor edits. I was thinking whether to change 1-n to One-to-Many to use the same format as the Laravel documentation, but I decided not to do anything. "super-specific" is overkill, a simple "specific" will do here. I was not sure about adding "from" in the following phrase, but I think it should be there: "Not just from the admin panel"
1 parent bf8f2d9 commit 3aa5aba

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

6.x/getting-started-crud-operations.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
**Duration:** 10 minutes
66

7-
Let's bring back the example in our first lesson. The Tags CRUD:
7+
Let's bring back the example from our first lesson. The Tags CRUD:
88

99
![Tag CRUD - List Entries Operation](https://backpackforlaravel.com/uploads/docs-4-0/getting_started/tag_crud_list_entries.png)
1010

@@ -58,20 +58,20 @@ In the example above, we've enabled the most common operations:
5858
- **Delete** - using a *button* in the *list view*
5959
- **Show** - using a *button* in the *list view*
6060

61-
These are the basic operations an admin can execute on an Eloquent model, thanks to Backpack. We do have additional operations (Reorder, Revisions, Clone, BulkDelete, BulkClone), and you can easily _create a custom operation_, but let's not get ahead of ourselves. Baby steps. **Let's go through the most important features of the operations you'll be using _all the time_: List, Create and Update**.
61+
These are the basic operations an admin can execute on an Eloquent model, thanks to Backpack. We do have additional operations (Reorder, Revisions, Clone, BulkDelete, and BulkClone), and you can easily _create a custom operation_, but let's not get ahead of ourselves. **Let's go through the most important features of the operations you'll be using _all the time_: List, Create, and Update**.
6262

6363
<a name="create-and-update-operations"></a>
64-
## Create & Update Operations
64+
## Create and Update Operations
6565

6666
![Tag CRUD - Edit Operation](https://backpackforlaravel.com/uploads/docs-4-0/getting_started/tag_crud_edit.png)
6767

6868
<a name="fields"></a>
6969
### Fields
7070

71-
Inside your Controller's ```setupCreateOperation()``` or ```setupUpdateOperation()``` method, you'll be able to define what fields you want the admin to see, when creating/updating entries. In the example above, we only have two fields, both using the ```text``` field type. So that's what's shown to the admin. When the admin presses _Save_, assuming your model has those two attributes as ```$fillable```, Backpack will save the entry and take you back to the List view. Keep in mind we're using a _pure_ Eloquent model. So of course, inside the model you could use accessors, mutators, events, etc.
71+
Inside your Controller's ```setupCreateOperation()``` or ```setupUpdateOperation()``` method, you'll be able to define which fields you want the admin to see, when creating/updating entries. In the example above, we only have two fields, both using the ```text``` field type. So that's what's shown to the admin. When the admin presses _Save_, assuming your model has those two attributes as ```$fillable```, Backpack will save the entry and take you back to the List view. Keep in mind we're using a _pure_ Eloquent model. So of course, inside the model you could use accessors, mutators, events, etc.
7272

7373

74-
But a lot of times, you won't just need text inputs. You'll need datepickers, upload buttons, 1-n relationship, n-n relationships, textareas, etc. For each field, you only need to define it properly in the Controller. Here are the most used methods to manipulate fields:
74+
But often, you won't just need text inputs. You'll need datepickers, upload buttons, 1-n relationships, n-n relationships, textareas, etc. For each field, you only need to define it properly in the Controller. Here are the most often used methods to manipulate fields:
7575

7676
```php
7777
CRUD::field('price');
@@ -82,7 +82,7 @@ CRUD::field('price')->after('name'); // move a field after a different field
8282
// you can of course chain these calls:
8383
CRUD::field('price')->label('Product price')->prefix('$')->after('name');
8484

85-
// you can also add multiple attribute in one go, by creating
85+
// you can also add multiple attributes in one go, by creating
8686
// a field using an array, instead of just its name (a string);
8787
// we call this the array syntax:
8888
CRUD::field([
@@ -94,14 +94,14 @@ CRUD::field([
9494
```
9595

9696
A typical *field definition* will need at least three things:
97-
- ```name``` - the attribute (column in the database), which will also become the name of the input;
98-
- ```type``` - the kind of field we'd like to use (text, number, select2, etc);
99-
- ```label``` - the human-readable label for the input (will be generated from ```name``` if not given);
97+
- ```name``` - the attribute (column in the database), which will also become the name of the input
98+
- ```type``` - the kind of field we want to use (text, number, select2, etc.)
99+
- ```label``` - the human-readable label for the input (will be generated from ```name``` if not given)
100100

101101

102-
You can use [one of the 44+ field types we've provided](/docs/{{version}}/crud-fields#default-field-types), or easily [create a custom field type](/docs/{{version}}/crud-fields#creating-a-custom-field-type) if you have some super-specific need that we haven't covered yet, or even [overwrite how a field type works](#overwriting-default-field-types). Take a few minutes and [browse the 44+ field types](/docs/{{version}}/crud-fields#default-field-types), to understand how the definition array differs from one to another and how many use cases you have already covered.
102+
You can use [one of the 44+ field types we've provided](/docs/{{version}}/crud-fields#default-field-types), or easily [create a custom field type](/docs/{{version}}/crud-fields#creating-a-custom-field-type) if you have a specific need that we haven't covered yet, or even [overwrite how a field type works](#overwriting-default-field-types). Take a few minutes and [browse the 44+ field types](/docs/{{version}}/crud-fields#default-field-types) to understand how the definition array differs from one to another and how many use cases you have already covered.
103103

104-
Let's take another example, slightly more complicated than the ```text``` fields we used above. Something you'll encounter all the time is relationship fields. So let's say the ```Tag``` model has an **n-n relationship** with an Article model:
104+
Let's take another example, slightly more complicated than the ```text``` fields we used above. Something you'll encounter all the time are relationship fields. So let's say the ```Tag``` model has an **n-n relationship** with an Article model:
105105

106106
```php
107107
public function articles()
@@ -123,10 +123,10 @@ CRUD::field([
123123
```
124124

125125
**Notes:**
126-
- If we call this inside ```setupUpdateOperation()``` it will only be added on that operation;
127-
- Because we haven't specified a ```label```, Backpack will take the "_articles_" name and turn it into a label: "_Articles_";
126+
- If we call this inside ```setupUpdateOperation()```, then it will only be added on that operation
127+
- Because we haven't specified a ```label```, Backpack will take the "_articles_" name and turn it into a label, "_Articles_"
128128

129-
If we had an Articles CRUD, and the reverse relationship defined on the ```Article``` model too, we could also add a ```select2_multiple``` field in the Article CRUD, to allow the admin to choose which tags apply to each article. This actually makes more sense than the above :-)
129+
If we had an Articles CRUD, and the reverse relationship defined on the ```Article``` model too, then we could also add a ```select2_multiple``` field in the Article CRUD to allow the admin to choose which tags apply to each article. This actually makes more sense than the above:
130130

131131
```php
132132
CRUD::field([
@@ -142,7 +142,7 @@ CRUD::field([
142142
<a name="callbacks"></a>
143143
### Callbacks
144144

145-
Developers coming from other CRUD systems will be looking for callbacks to run ```before_insert```, ```before_update```, ```after_insert```, ```after_update```. **There are no callbacks in Backpack**.
145+
Developers coming from other CRUD systems will be looking for callbacks to run ```before_insert```, ```before_update```, ```after_insert```, and ```after_update```. **There are no callbacks in Backpack**.
146146

147147
Remember that Backpack is using Eloquent models. That means you can do X when Y is happening, by using the [model events](https://laravel.com/docs/10.x/eloquent#events). For example, in your MonsterCrudController you can do:
148148

@@ -162,7 +162,7 @@ public function setup() {
162162
}
163163
```
164164

165-
Alternatively, if you do need to change how an operation does something... that's dead-simple too. The ```store()``` and ```update()``` code is inside a trait, so you can easily override that method, and call it inside your new method. For example, here's how we can do things before/after an item is saved in the Create operation:
165+
Alternatively, if you need to change how an operation does something, then that's simple too. The ```store()``` and ```update()``` code is inside a trait, so you can easily override that method and call it inside your new method. For example, here's how we can do things before/after an item is saved in the Create operation:
166166

167167
```php
168168
<?php
@@ -187,19 +187,19 @@ class ProductCrudController extends CrudController
187187
}
188188
```
189189

190-
>But before you do that, ask yourself - **_is this something that should be done when an entry is added/updated/deleted from the application, too_**? Not just the admin panel? If so, a better place for it would be the Model. Remember your Model is a pure Eloquent Model, so the cleanest way might be to use [Eloquent Event Observers](https://laravel.com/docs/6.0/eloquent#events) or [accessors and mutators](https://laravel.com/docs/master/eloquent-mutators#accessors-and-mutators).
190+
>But before you do that, ask yourself - **_is this something that should be done when an entry is added/updated/deleted from the application too_**? Not just from the admin panel? If so, a better place for it would be the Model. Remember your Model is a pure Eloquent Model, so the cleanest way might be to use [Eloquent Event Observers](https://laravel.com/docs/6.0/eloquent#events) or [accessors and mutators](https://laravel.com/docs/master/eloquent-mutators#accessors-and-mutators).
191191
192192
<a name="list-entries-operation"></a>
193193
## List Operation
194194

195-
List shows the admin a table with all entries. On the front-end, the information is pulled using AJAX calls, and shown using DataTables. It's the most feature-packed operation in Backpack, but right now we're just going through the most important features you need to know about: columns, filters and buttons.
195+
List shows the admin a table with all entries. On the front-end, the information is pulled using AJAX calls, and shown using DataTables. It's the most feature-packed operation in Backpack, but right now we're just going through the most important features you need to know about: columns, filters, and buttons.
196196

197197
You should configure the List operation inside the ```setupListOperation()``` method.
198198

199199
<a name="columns"></a>
200200
### Columns
201201

202-
Columns help you specify *which* attributes are shown in the table and *in which order*. Their syntax is a;almost identical to fields. In fact, you'll find each Backpack field has a corresponding column, with the same name and syntax:
202+
Columns help you specify *which* attributes are shown in the table and *in which order*. Their syntax is almost identical to fields. In fact, you'll find each Backpack field has a corresponding column, with the same name and syntax:
203203

204204
```php
205205
CRUD::column($column_definition_array); // add a single column, at the end of the table
@@ -215,7 +215,7 @@ CRUD::removeColumns(['column_name_1', 'column_name_2']); // remove an array of c
215215
CRUD::setColumnsDetails(['column_1', 'column_2'], ['attribute' => 'value']);
216216
```
217217

218-
You can use one of the [44+ column types](/docs/{{version}}/crud-columns#default-column-types) to show information to the user in the table, or easily [create a custom column type](/docs/{{version}}/crud-columns#creating-a-custom-column-type), if you have a super-specific need. Here's an example of using the methods above:
218+
You can use one of the [44+ column types](/docs/{{version}}/crud-columns#default-column-types) to show information to the user in the table, or easily [create a custom column type](/docs/{{version}}/crud-columns#creating-a-custom-column-type) if you have a specific need. Here's an example of using the methods above:
219219

220220
```php
221221
CRUD::column([
@@ -233,22 +233,22 @@ CRUD::column('text'); // adds a text column, at the end of the stack
233233

234234
![Monster CRUD - List Entries Filters](https://backpackforlaravel.com/uploads/docs-4-0/getting_started/backpack_filters.png)
235235

236-
Filters provide an easy way for the admin to well… _filter_ the List table. The syntax is very similar to Fields and Columns and you can use one of the [existing 8 filter types](/docs/{{version}}/crud-filters) or easily [create a custom filter](/docs/{{version}}/crud-filters#creating-custom-filters). Note that this is a PRO feature.
236+
Filters provide an easy way for the admin to _filter_ the List table. The syntax is very similar to Fields and Columns and you can use one of the [existing 8 filter types](/docs/{{version}}/crud-filters) or easily [create a custom filter](/docs/{{version}}/crud-filters#creating-custom-filters). Note that this is a PRO feature.
237237

238238
```php
239239
CRUD::addFilter($options, $values, $filter_logic);
240240
CRUD::removeFilter($name);
241241
CRUD::removeAllFilters();
242242
```
243243

244-
For more on this, check out the [filters documentation page](/docs/{{version}}/crud-filters), when you need them.
244+
For more on filters, check out the [filters documentation page](/docs/{{version}}/crud-filters).
245245

246246
<a name="buttons"></a>
247247
### Buttons
248248

249249
![Tag CRUD - List Entries Buttons](https://backpackforlaravel.com/uploads/docs-4-0/getting_started/backpack_buttons.png)
250250

251-
If you want to add a custom button to an entry, you can do that. If you want to remove a button, you can also do that. Look for the [buttons documentation](/docs/{{version}}/crud-buttons) when you need it.
251+
If you want to add a custom button to an entry, you can do that. If you want to remove a button, you can also do that. Check out the [buttons documentation](/docs/{{version}}/crud-buttons).
252252

253253
```php
254254
// positions: 'beginning' and 'end'
@@ -259,7 +259,7 @@ CRUD::removeButton($name);
259259
CRUD::removeButtonFromStack($name, $stack);
260260
```
261261

262-
**That's it for today!** Thanks for sticking with us this long. This has been the most important and longest lesson. You can go ahead and [install Backpack](/docs/{{version}}/installation) now, as you've already gone through the most important features. Or [read the next lesson](/docs/{{version}}/getting-started-advanced-features), about advanced features.
262+
**That's it!** Thanks for sticking with us this long. This has been the most important and longest lesson. You can go ahead and [install Backpack](/docs/{{version}}/installation) now as you've already gone through the most important features. Or [read the next lesson](/docs/{{version}}/getting-started-advanced-features) about advanced features.
263263

264264

265265
<br>

0 commit comments

Comments
 (0)