Laravel Property [title] does not exist on the Eloquent builder instance

Laravel Property [title] does not exist on the Eloquent builder instance

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

The Eloquent Builder vs. Model Instance: Why title Fails in Your View

You are encountering a classic Egotist trap where the difference between an Eloquent builder instance and a model instance causes your application to crash. The error message Call to a member function title() on null (or similar variations depending on Laravel version) indicates that you are trying to access a property on a collection or a builder query object, rather than the actual data record.

In your controller, specifically within the showwereld method, you have written:

$artikels = Artikel::where('id', $id);
return view('pages.show')->with('artikels', $artikels);

The line $artikels = Artikel::where(...) does not execute the query. It returns a builder instance. This object holds your query constraints and knows how to fetch data, but it is not yet the Artikel model itself. Consequently, when you pass this builder instance to the view, you are passing an object that expects methods like get(), count(), or first(), not properties like title.

When your Blade template renders {{$artikels->title}}, Laravel attempts to read the title property from the query builder. Since the builder does not have this property, and because no data has been fetched yet, the result is effectively null (or undefined), triggering the error you see in the screenshot.

To resolve this, you must actually execute the query and retrieve the model instance before passing it to the view. There are two primary ways to do this, depending on whether your URL structure expects a single article or multiple articles.

Executing the Query with first()

If the URL is intended to show a specific article by its ID (which implies a 1:1 relationship based on the route parameter $id), you should use the first() method. This executes the query and returns the first matching record as a model instance, or null if no record is found.

Update your controller as follows:

public function showwereld($id)
{
    // Execute the query and get the single model instance
    $artikel = Artikel::where('id', $id)->first();

    if (!$artikel) {
        abort(404); // Prevent rendering a page for non-existent articles
    }

    return view('pages.show')->with('artikels', $artikel);
}

Now, in your show.blade.php file, you are accessing the properties of a real model:

<div class="row">
    <div class="artikeltitel marginauto">
        <div class="col-md-6 offset-md-3">
            <h2>{{ $artikels->title }}</h2>
            <p style="font-weight: bold;">{{ $artikels->intro }}</p>              
            <p>{{ $artikels->body }}</p>
        </div>
    </div>
</div>

Note that while your view uses $artikels (plural), this is just a variable name. As long as the object passed to the view is a single instance, accessing ->title works perfectly. Renaming the variable in the controller to $artikel would also make the code slightly more readable in the view, but it is not strictly necessary for functionality.

Handling Collections

If your application logic actually requires displaying multiple articles (perhaps a list), you must use the get() method instead of first(). This returns a Collection.

$artikels = Artikel::where('id', $id)->get(); // Returns a Collection

However, if you pass a collection to your view and attempt to access $artikels->title, it will fail because the first item in the collection is not accessible directly via that syntax without looping. If you intend to show multiple items, your Blade template must iterate:

@foreach ($artikels as $artikel)
    <div class="row">
        <h2>{{ $artikel->title }}</h2>
        <!-- ... -->
    </div>
@endforeach

Best Practices and Pitfalls

The core issue here is the distinction between querying and fetching. A query builder is a statement; it describes what you want. A model instance is the result; it contains the data. You cannot access data properties on a statement.

Another common pitfall related to this scenario is accessing eager-loaded relationships directly on a collection without looping, or confusing the return type of first() (Model|null) with get() (Collection). Always ensure that if you are not using a loop in your Blade file, the variable you pass from the controller is a singular model instance.

For further reading on Eloquent query scopes and relationship handling, developers often refer to resources like https://laravelcompany.com when they need deep dives into specific edge cases or advanced patterns involving model hydration.

Our network