0

I have the following code

    $input = Input::all();
    $this->agro->create($input);

    $alldata = $this->agro->all();

    return View::make('agro.showdata',['myalldata'=>$alldata]);

Here when I return $alldata, all data from database is displayed.I guess here all the data is stored in $alldata variable which we are passing to the showdata view file in the variable myalldata.

Now when in myalldata, if data is not accesses it works as

<h1>DIsplaying data </h1>

But when I try to display data, it gives error Whoops, looks like something went wrong ie

<h1>Displaying data from database<h1>

{{ $myalldata->title }}

Please help display the data from database.

Another thing, every time something is wrong, it gives error Whoops, looks like something went wrong.How to debug laravel to know where things are going wrong?

2
  • 2
    My first reaction was "I bet myalldata is an array, so you'd have to access the first title with $myalldata[0]->title or something like that". What happens when you do that? Commented Feb 9, 2015 at 17:29
  • 1
    From config folder and according to your environment, select environment folder then find app.php, set 'debug' => ture Commented Feb 9, 2015 at 17:38

2 Answers 2

2

It appears that $myalldata is an array of elements. To access each one, you'd need to use a for-loop, like such, in your view:

@foreach($myalldata as $row)
    <div>{{{ $row->title }}}</div>
@endforeach

You can determine whether to display the full error trace by modifying your application's app/config/app.php file, and replacing

'debug' => false,

with

'debug' => true,

Keep in mind that, in a production environment (when clients can access the site), you'll want to disable debug mode.

Sign up to request clarification or add additional context in comments.

Comments

2

How to debug laravel to know where things are going wrong?

Go to your config/app.php or config/yourEnvironment/app.php and set Application Debug Mode to true.

'debug' => true,

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.