PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, February 8, 2022

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

 February 08, 2022     laravel, laravel-blade, php     No comments   

Issue

I am getting an error while trying to display data from the database.This problem occurred by other people who have created posts on this website. but they have a foreach loop and I don't. so all the answers given for this problem do not work.

article controller

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

show.blade.php

<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>

enter image description here


Solution

this on controller

public function index()
{
    $artikel =  Artikel::where('category_id', '1')->first();
    return view('pages.wereld',compact('artikel'));
}

in view:

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


Answered By - Ahmed Atoui
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing