Skip to main content

Customer View Page with Infolist

Premium
4 min read

Next, we want to build an info list (View) page for our Customers. This page has to display all the information we have on our Customer along with a list of Pipeline Status logs:

In this lesson, we will do the following:

  • Create an InfoList View
  • Update Table row click to point to the View page
  • Create a custom component to display the Pipeline Status logs

Creating InfoList Page

Let's get to work and create a new file for our View:

php artisan make:filament-page ViewCustomer --resource=CustomerResource --type=ViewRecord

This should create the following file:

app/Filament/Resources/CustomerResource/Pages/ViewCustomer.php

namespace App\Filament\Resources\CustomerResource\Pages;
 
use App\Filament\Resources\CustomerResource;
use Filament\Resources\Pages\CreateRecord;
use Filament\Resources\Pages\ViewRecord;
 
class ViewCustomer extends ViewRecord
{
protected static string $resource = CustomerResource::class;
}

Once this is done, we can go ahead and create...

The Full Lesson is Only for Premium Members

Want to access all of our courses? (30 h 01 min)

You also get:

55 courses
Premium tutorials
Access to repositories
Private Discord
Get Premium for $129/year or $29/month

Already a member? Login here

Comments & Discussion

A
Ayo ✓ Link copied!

Hello there, i got this

foreach() argument must be of type array|object, null given

C:\laragon\www\crm\resources\views\infolists\components\pipeline-stage-history-list.blade.php: 2

M
Modestas ✓ Link copied!

Hi, this seems like a missed step somewhere. Could you add a bit more code on what you did or flare report share?

The error message says that there are no pipeline stages on your Customer, which is due to bad relationship name or a typo somewhere (could be missed code piece or anything else like that)

RA
Richard A. Hoyle ✓ Link copied!

Having a problem if the customer has not been moved up from a lead and you click on that client in the list then you get the

foreach() argument must be of type array|object, null given Error

But if the customer has been moved up to say Contact Made you no longer get the error and the customer data is displayed

What can we do to fix this problem?

Also gitting a N+1 Error message but if you click on the "ok" button it puls up the page

I see that this problem is fixed in your github repository however.

M
Modestas ✓ Link copied!

The problem that you are describing is from misconfiguration. You have to create a customer with at least 1 pipeline stage and observer has to catch that it was there. This will create 1 entry and prevent this error.

What you might have done differently from this tutorial - skipped the fresh migration run after implementing the observer. Try to run php artisan migrate:fresh --seed and see if you can open customers view. If not, then simply add @if(count($getState()) > 0) around the foreach.

As for N+1 - could you expand where that happens? And does it still exist on the last lesson that we have?

MS
Marcos Sánchez ✓ Link copied!

hello for me It works with both modifications, the relationship in tables was wrong, which is solved with the refresh and correct functioning is ensured by testing if getState > 0

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.