Skip to content

Commit c09e3f3

Browse files
authored
Merge pull request #5726 from Laravel-Backpack/fix-getting-started-text
FIx the getting started text and add CalendarOperation to the premium…
2 parents 72850d7 + b028eab commit c09e3f3

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

src/resources/views/ui/inc/getting_started.blade.php

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,25 @@
2121
<p>To dig a little deeper, <a href="#" data-bs-toggle="collapse" data-bs-target="#customizeUsersCRUD" data-toggle="collapse" data-target="#customizeUsersCRUD" aria-expanded="true" aria-controls="customizeUsersCRUD">let's make a few changes to the Users CRUD <i class="la la-angle-double-right"></i></a></p>
2222

2323
<div class="collapse" id="customizeUsersCRUD">
24-
<p><strong>1. When Listing, let's remove the "password" column</strong> - no point in showing the hash. To do that, go to <code class="text-primary bg-light p-1 rounded">UserCrudController::setupListOperation()</code> and remove the line saying <code class="text-primary bg-light p-1 rounded">CRUD::column('password');</code> - easy-peasy, right?</p>
24+
<p><strong>1. When listing, let's remove <code>setFromDb()</code> and define each column</strong>. To do that, navigate to <code class="text-primary bg-light p-1 rounded">UserCrudController::setupListOperation()</code> and remove the line that says <code class="text-primary bg-light p-1 rounded">setFromDb();</code> - Afterward, manually add the columns for <em>name</em> and <em>email</em>.</p>
25+
<p>
26+
<pre class="language-php rounded"><code class="language-php p-1">
27+
protected function setupListOperation()
28+
{
29+
CRUD::column('name');
30+
CRUD::column('email');
31+
}
32+
</code></pre>
33+
</p>
2534
<p><strong>2. On Create & Update, let's add validation to forms</strong>. There are <a href="https://backpackforlaravel.com/docs/crud-operation-create#validation?ref=getting-started-widget" target="_blank">multiple ways to add validation</a> but we've already chosen the simplest, <a href="https://backpackforlaravel.com/docs/crud-operation-create#validating-fields-using-field-attributes?ref=getting-started-widget" target="_blank">validation using field attributes</a>. Let's go to <code class="text-primary bg-light p-1 rounded">setupCreateOperation()</code> and specify our validation rules directly on the fields:
2635
<p>
2736
<pre class="language-php rounded"><code class="language-php p-1">
28-
CRUD::field('name')->validationRules('required|min:5');
29-
CRUD::field('email')->validationRules('required|email|unique:users,email');
30-
CRUD::field('password')->validationRules('required');
37+
protected function setupCreateOperation()
38+
{
39+
CRUD::field('name')->validationRules('required|min:5');
40+
CRUD::field('email')->validationRules('required|email|unique:users,email');
41+
CRUD::field('password')->validationRules('required');
42+
}
3143
</code></pre>
3244
</p>
3345
<p><strong>3. On Create, let's hash the password.</strong> Currently, if we create a new User, it'll work. But if you look in the database... you'll notice the password is stored in plain text. We don't want that - we want it hashed. There are <a href="https://backpackforlaravel.com/docs/crud-operation-create#use-events-in-your-setup-method?ref=getting-started-widget" target="_blank">multiple ways to achieve this too</a>. Let's use Model Events inside <code class="text-primary bg-light p-1 rounded">setupCreateOperation()</code>. Here's how our method could look, when we also tap into the <code class="text-primary bg-light p-1 rounded">creating</code> event, to hash the password:</p>
@@ -38,7 +50,7 @@ protected function setupCreateOperation()
3850
CRUD::field('name')->validationRules('required|min:5');
3951
CRUD::field('email')->validationRules('required|email|unique:users,email');
4052
CRUD::field('password')->validationRules('required');
41-
53+
4254
// if you are using Laravel 10+ your User model should already include the password hashing in the model casts.
4355
// if that's the case, you can skip this step. You can check your model $casts property or `casts()` method.
4456
\App\Models\User::creating(function ($entry) {
@@ -114,6 +126,7 @@ protected function setupUpdateOperation()
114126
<li><strong><a target="_blank" href="https://backpackforlaravel.com/products/devtools?ref=getting-started-widget">DevTools</a></strong> - easily generate Laravel migrations and models, from a web interface</li>
115127
<li><strong><a target="_blank" href="https://backpackforlaravel.com/products/figma-template?ref=getting-started-widget">FigmaTemplate</a></strong> - create designs and mockups that are easy to implement in Backpack</li>
116128
<li><strong><a target="_blank" href="https://backpackforlaravel.com/products/editable-columns?ref=getting-started-widget">EditableColumns</a></strong> - let your admins make quick edits, right from the table view</li>
129+
<li><strong><a target="_blank" href="https://backpackforlaravel.com/products/calendar-operation?ref=getting-started-widget">CalendarOperation</a></strong> - let your admins see and manage model entries, directly on a calendar</li>
117130
</ul>
118131
</div>
119132
</div>

0 commit comments

Comments
 (0)