0

I must be missing something, since my code isn't working, but I have tried to figure it out for a while now without any luck.

I am trying to output a single column content from a table, which represents all the text-bits throughout a simple website, which I want to be able to edit and update in the table, with a simple cms, which I have created.

These are my controllers

And my Model

I would like to do this in my index.blade.php {{ $indexHeading }}

I get the error message: undefined variable: texts, I must be missing a link between something.

I am a beginner, and I'm hoping I just made a simple mistake, which I am not skilled enough to see :)

Thanks in advance!

5
  • Can you post blade file and full error message? Commented Apr 3, 2017 at 11:57
  • That makes sense, how would you do that? :) return view('index', ['texts' => $texts]); It is in that line, right? Commented Apr 3, 2017 at 11:58
  • Could you please edit your question and post your code? It's difficult with images! Commented Apr 3, 2017 at 11:59
  • Ah sorry, I thought it might be easier to see the different files Commented Apr 3, 2017 at 12:00
  • @Rahi I can't post any more photos in MainController.php line 17 at HandleExceptions->handleError(8, 'Undefined variable: texts', 'E:\\projects\\prettyfitlv\\app\\Http\\Controllers\\MainController.php', 17, array('indexHeading' => 'SomethingSomethingSomething')) in MainController.php line 17 Commented Apr 3, 2017 at 12:03

2 Answers 2

2

In your MainController you are passing texts without creating it.

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

2 Comments

But is it the right way to pass texts? Do I create it by saying $texts = Text::find....?
try rename $texts with $indexHeading or pass $indexHeading instead of $texts
0

You have to pass data from your controller to view

View('index',['texts'=>$yourvalue);

Then you can access text variable in the view file.

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.