You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All we need to do is to add `name` parameter to `$searchable` property in `App\Sections\Leads\Repositories\LeadRepository` and in this case we need to use `like` operator:
Now let's add a new filtering option by status. Firstly we need to set up an additional input field in `resources/views/sections/leads/index.blade.php` template:
What about sorting? We have an option to sort leads by names, let's make it work. Again all we need to do is to add `name` parameter to model's `$orderable` property and repository package will do the rest:
337
+
338
+
```php
339
+
// App\Sections\Leads\Models\Lead
340
+
public $orderable = ['name'];
341
+
```
342
+
343
+
Now let's add sorting by a lead status right into a table column. Firstly update `index` template:
What if we need to create a new record? If you click the yellow action button, a new modal window will open, let's update it so we can create new leads.
379
+
380
+
For now, all we have is one input field for a name. Let's add one more for status:
Respective method to `LeadController` (we'll keep things as simple as possible for easy understanding):
409
+
410
+
```php
411
+
public function store(Request $request)
412
+
{
413
+
$this->leads->create($request->all());
414
+
}
415
+
```
416
+
417
+
And column names into `$fillable` model's property:
418
+
419
+
```php
420
+
public $fillable = ['name', 'status'];
421
+
```
422
+
423
+
We can now create new leads, but it'd be really helpful if the table could refresh its content after that. To achieve that, we need to handle a successful response after creating a new record:
All we do here is emiting event, now table will refresh after successfully creating a new record.
431
+
432
+
## Customizing table & updating existing leads
433
+
434
+
At last, we want to implement something fun and really useful. How about modifying our table and creating a new modal window to update any of our leads data.
435
+
436
+
Let's add new menu to each table row, with `edit lead` item:
0 commit comments