From b028eabd40e441fb2606d2e65a7e674938d07a23 Mon Sep 17 00:00:00 2001 From: jcastroa87 Date: Wed, 27 Nov 2024 14:28:37 -0300 Subject: [PATCH] FIx the getting started text and add CalendarOperation to the premium add-ons list --- .../views/ui/inc/getting_started.blade.php | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/resources/views/ui/inc/getting_started.blade.php b/src/resources/views/ui/inc/getting_started.blade.php index 5ff070c30e..acb6e2a6f8 100644 --- a/src/resources/views/ui/inc/getting_started.blade.php +++ b/src/resources/views/ui/inc/getting_started.blade.php @@ -21,13 +21,25 @@

To dig a little deeper, let's make a few changes to the Users CRUD

-

1. When Listing, let's remove the "password" column - no point in showing the hash. To do that, go to UserCrudController::setupListOperation() and remove the line saying CRUD::column('password'); - easy-peasy, right?

+

1. When listing, let's remove setFromDb() and define each column. To do that, navigate to UserCrudController::setupListOperation() and remove the line that says setFromDb(); - Afterward, manually add the columns for name and email.

+

+


+                  protected function setupListOperation()
+                  {
+                      CRUD::column('name');
+                      CRUD::column('email');
+                  }
+                  
+

2. On Create & Update, let's add validation to forms. There are multiple ways to add validation but we've already chosen the simplest, validation using field attributes. Let's go to setupCreateOperation() and specify our validation rules directly on the fields:


-                    CRUD::field('name')->validationRules('required|min:5');
-                    CRUD::field('email')->validationRules('required|email|unique:users,email');
-                    CRUD::field('password')->validationRules('required');
+                  protected function setupCreateOperation()
+                  {
+                      CRUD::field('name')->validationRules('required|min:5');
+                      CRUD::field('email')->validationRules('required|email|unique:users,email');
+                      CRUD::field('password')->validationRules('required');
+                  }
                   

3. On Create, let's hash the password. 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 multiple ways to achieve this too. Let's use Model Events inside setupCreateOperation(). Here's how our method could look, when we also tap into the creating event, to hash the password:

@@ -38,7 +50,7 @@ protected function setupCreateOperation() CRUD::field('name')->validationRules('required|min:5'); CRUD::field('email')->validationRules('required|email|unique:users,email'); CRUD::field('password')->validationRules('required'); - + // if you are using Laravel 10+ your User model should already include the password hashing in the model casts. // if that's the case, you can skip this step. You can check your model $casts property or `casts()` method. \App\Models\User::creating(function ($entry) { @@ -114,6 +126,7 @@ protected function setupUpdateOperation()
  • DevTools - easily generate Laravel migrations and models, from a web interface
  • FigmaTemplate - create designs and mockups that are easy to implement in Backpack
  • EditableColumns - let your admins make quick edits, right from the table view
  • +
  • CalendarOperation - let your admins see and manage model entries, directly on a calendar