Laravel: Variable not being passed from controller to view












0















using Laravel 5.6.28 my route on web.php file looks like this:



Route::get('kitysoftware/besttrades', 'SectorsController@besttradesview');


My controller with bestrasdeview function:



class SectorsController extends Controller
{
public function besttradesview()
{
$sectors = DB::table('Sectors')->get();
foreach ($sectors as $sector) {
echo $sector->SectorName;
}
//passing variable sectors1 to my view (is = $sector)
return view('besttradesview', ['sectors1' => $sector]);
}}


My view Bestradesview.blade.php is:



<form method="GET">
<div class="selectsector">
<Select class="selectsector" name = "sectors">
<option value="{{ sectors1 }}"></option>
<!-- test#2: <option value="{{ $sectors1->sector }}"></option> -->
<!-- test#3: <option value="{{ $sectors1->sector }}"></option> -->
</form>
</select>



  • And i get this error: Use of undefined constant sectors1 - assumed
    'sectors1' (this will throw an Error in a future version of PHP)

  • When testing #2 commented line instead i get another error: Symfony Component Debug Exception FatalErrorException (E_UNKNOWN)
    Cannot use for reading


  • When testing #3 commented line without i get another error: Use of undefined constant sectors1 - assumed 'sectors1' (this will throw an Error in a future version of PHP)



Probably it's pretty simple but it's driving me nuts because i can't see why the variable is not passing to the view.
I know it's reading my table because if i remove the last return view call line on my controller, it echoes out all the values from my SectorName column, but i want it on a select dropdown menu.



I have been reading the docs, forums and watching laracast videos without luck. Any insight or just pointing me out to where to learn the proper sintax solution will be appreciatted.
Thanks in advance










share|improve this question



























    0















    using Laravel 5.6.28 my route on web.php file looks like this:



    Route::get('kitysoftware/besttrades', 'SectorsController@besttradesview');


    My controller with bestrasdeview function:



    class SectorsController extends Controller
    {
    public function besttradesview()
    {
    $sectors = DB::table('Sectors')->get();
    foreach ($sectors as $sector) {
    echo $sector->SectorName;
    }
    //passing variable sectors1 to my view (is = $sector)
    return view('besttradesview', ['sectors1' => $sector]);
    }}


    My view Bestradesview.blade.php is:



    <form method="GET">
    <div class="selectsector">
    <Select class="selectsector" name = "sectors">
    <option value="{{ sectors1 }}"></option>
    <!-- test#2: <option value="{{ $sectors1->sector }}"></option> -->
    <!-- test#3: <option value="{{ $sectors1->sector }}"></option> -->
    </form>
    </select>



    • And i get this error: Use of undefined constant sectors1 - assumed
      'sectors1' (this will throw an Error in a future version of PHP)

    • When testing #2 commented line instead i get another error: Symfony Component Debug Exception FatalErrorException (E_UNKNOWN)
      Cannot use for reading


    • When testing #3 commented line without i get another error: Use of undefined constant sectors1 - assumed 'sectors1' (this will throw an Error in a future version of PHP)



    Probably it's pretty simple but it's driving me nuts because i can't see why the variable is not passing to the view.
    I know it's reading my table because if i remove the last return view call line on my controller, it echoes out all the values from my SectorName column, but i want it on a select dropdown menu.



    I have been reading the docs, forums and watching laracast videos without luck. Any insight or just pointing me out to where to learn the proper sintax solution will be appreciatted.
    Thanks in advance










    share|improve this question

























      0












      0








      0








      using Laravel 5.6.28 my route on web.php file looks like this:



      Route::get('kitysoftware/besttrades', 'SectorsController@besttradesview');


      My controller with bestrasdeview function:



      class SectorsController extends Controller
      {
      public function besttradesview()
      {
      $sectors = DB::table('Sectors')->get();
      foreach ($sectors as $sector) {
      echo $sector->SectorName;
      }
      //passing variable sectors1 to my view (is = $sector)
      return view('besttradesview', ['sectors1' => $sector]);
      }}


      My view Bestradesview.blade.php is:



      <form method="GET">
      <div class="selectsector">
      <Select class="selectsector" name = "sectors">
      <option value="{{ sectors1 }}"></option>
      <!-- test#2: <option value="{{ $sectors1->sector }}"></option> -->
      <!-- test#3: <option value="{{ $sectors1->sector }}"></option> -->
      </form>
      </select>



      • And i get this error: Use of undefined constant sectors1 - assumed
        'sectors1' (this will throw an Error in a future version of PHP)

      • When testing #2 commented line instead i get another error: Symfony Component Debug Exception FatalErrorException (E_UNKNOWN)
        Cannot use for reading


      • When testing #3 commented line without i get another error: Use of undefined constant sectors1 - assumed 'sectors1' (this will throw an Error in a future version of PHP)



      Probably it's pretty simple but it's driving me nuts because i can't see why the variable is not passing to the view.
      I know it's reading my table because if i remove the last return view call line on my controller, it echoes out all the values from my SectorName column, but i want it on a select dropdown menu.



      I have been reading the docs, forums and watching laracast videos without luck. Any insight or just pointing me out to where to learn the proper sintax solution will be appreciatted.
      Thanks in advance










      share|improve this question














      using Laravel 5.6.28 my route on web.php file looks like this:



      Route::get('kitysoftware/besttrades', 'SectorsController@besttradesview');


      My controller with bestrasdeview function:



      class SectorsController extends Controller
      {
      public function besttradesview()
      {
      $sectors = DB::table('Sectors')->get();
      foreach ($sectors as $sector) {
      echo $sector->SectorName;
      }
      //passing variable sectors1 to my view (is = $sector)
      return view('besttradesview', ['sectors1' => $sector]);
      }}


      My view Bestradesview.blade.php is:



      <form method="GET">
      <div class="selectsector">
      <Select class="selectsector" name = "sectors">
      <option value="{{ sectors1 }}"></option>
      <!-- test#2: <option value="{{ $sectors1->sector }}"></option> -->
      <!-- test#3: <option value="{{ $sectors1->sector }}"></option> -->
      </form>
      </select>



      • And i get this error: Use of undefined constant sectors1 - assumed
        'sectors1' (this will throw an Error in a future version of PHP)

      • When testing #2 commented line instead i get another error: Symfony Component Debug Exception FatalErrorException (E_UNKNOWN)
        Cannot use for reading


      • When testing #3 commented line without i get another error: Use of undefined constant sectors1 - assumed 'sectors1' (this will throw an Error in a future version of PHP)



      Probably it's pretty simple but it's driving me nuts because i can't see why the variable is not passing to the view.
      I know it's reading my table because if i remove the last return view call line on my controller, it echoes out all the values from my SectorName column, but i want it on a select dropdown menu.



      I have been reading the docs, forums and watching laracast videos without luck. Any insight or just pointing me out to where to learn the proper sintax solution will be appreciatted.
      Thanks in advance







      php html laravel-5 drop-down-menu eloquent






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 15 '18 at 23:50









      gallo2000svgallo2000sv

      256




      256
























          2 Answers
          2






          active

          oldest

          votes


















          0














          It looks like you're trying to populate the select options from the query. If that's the case, your loop is in the wrong place.



          Take the loop out of the controller method, and pass the $sectors collection directly to the view.



          public function besttradesview()
          {
          $sectors = DB::table('Sectors')->get();
          return view('besttradesview', ['sectors1' => $sectors]);
          }


          Then loop in the view to output the options.



          <select class="selectsector" name="sectors">
          @foreach($sectors1 as $sector)
          <option>{{ $sector->SectorName }}</option>
          @endforeach
          </select>


          I assumed you wanted some text in the option. If you use the sector name as the option text it will also be used as the option value by default. If you want to use something else for the value, it would be like this, for example:



          <option value="{{ $sector->id }}">{{ $sector->SectorName }}</option>





          share|improve this answer
























          • Thanks a lot. It's working now. I was wondering the right place to place that foreach, i thought to keep only html in my views. But got it working changing it as per your suggestion. Makes more sense.

            – gallo2000sv
            Nov 16 '18 at 0:34











          • You're welcome. Generally, keeping html in the view is the right way to look at it. But most template systems like blade have looping structures for this kind of thing. It isn't really like putting your business logic in the presentation layer, though. It's just kind of necessary for rendering a template with repeated elements effectively.

            – Don't Panic
            Nov 16 '18 at 0:40



















          -1














          Change,



          return view('besttradesview', ['sectors1' => $sector]);


          To,



           return view('besttradesview', ['sectors1' => $sectors]);


          Notice the s in $sectors ($sectors = DB::table('Sectors')->get();) and in the actual view, it should be $sectors1 not just sectors1.



          You also need to loop through actual sector:



          @foreach ($sectors1 as $sector)
          <option>{{ $sector->SectorName }}</option>
          @endforeach


          Also, I would definitely suggest creating a model for your Sectors table rather than using the DB:: facade. You should make use of the M in MVC.






          share|improve this answer


























          • Thanks for your reply. However changed the s and still same error: Use of undefined constant sectors1 - assumed 'sectors1' (this will throw an Error in a future version of PHP) I thought it supposed to use the variable coming from the foreach, not the one with the query. I have a model called Sectors as well. I thought this was the proper way to connect with that model

            – gallo2000sv
            Nov 16 '18 at 0:06













          • @gallo2000sv please see my edit: 'and in the actual view, it should be $sectors1 not just sectors1.'

            – Script47
            Nov 16 '18 at 0:07











          • Thanks again. I tried again after changing the s and putting $sectors1 in the view, and getting: Trying to get property 'sector' of non-object

            – gallo2000sv
            Nov 16 '18 at 0:11











          • @gallo2000sv you also need to loop through the actual sectors in the view. Check the my update @foreach.

            – Script47
            Nov 16 '18 at 0:13











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53329488%2flaravel-variable-not-being-passed-from-controller-to-view%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          It looks like you're trying to populate the select options from the query. If that's the case, your loop is in the wrong place.



          Take the loop out of the controller method, and pass the $sectors collection directly to the view.



          public function besttradesview()
          {
          $sectors = DB::table('Sectors')->get();
          return view('besttradesview', ['sectors1' => $sectors]);
          }


          Then loop in the view to output the options.



          <select class="selectsector" name="sectors">
          @foreach($sectors1 as $sector)
          <option>{{ $sector->SectorName }}</option>
          @endforeach
          </select>


          I assumed you wanted some text in the option. If you use the sector name as the option text it will also be used as the option value by default. If you want to use something else for the value, it would be like this, for example:



          <option value="{{ $sector->id }}">{{ $sector->SectorName }}</option>





          share|improve this answer
























          • Thanks a lot. It's working now. I was wondering the right place to place that foreach, i thought to keep only html in my views. But got it working changing it as per your suggestion. Makes more sense.

            – gallo2000sv
            Nov 16 '18 at 0:34











          • You're welcome. Generally, keeping html in the view is the right way to look at it. But most template systems like blade have looping structures for this kind of thing. It isn't really like putting your business logic in the presentation layer, though. It's just kind of necessary for rendering a template with repeated elements effectively.

            – Don't Panic
            Nov 16 '18 at 0:40
















          0














          It looks like you're trying to populate the select options from the query. If that's the case, your loop is in the wrong place.



          Take the loop out of the controller method, and pass the $sectors collection directly to the view.



          public function besttradesview()
          {
          $sectors = DB::table('Sectors')->get();
          return view('besttradesview', ['sectors1' => $sectors]);
          }


          Then loop in the view to output the options.



          <select class="selectsector" name="sectors">
          @foreach($sectors1 as $sector)
          <option>{{ $sector->SectorName }}</option>
          @endforeach
          </select>


          I assumed you wanted some text in the option. If you use the sector name as the option text it will also be used as the option value by default. If you want to use something else for the value, it would be like this, for example:



          <option value="{{ $sector->id }}">{{ $sector->SectorName }}</option>





          share|improve this answer
























          • Thanks a lot. It's working now. I was wondering the right place to place that foreach, i thought to keep only html in my views. But got it working changing it as per your suggestion. Makes more sense.

            – gallo2000sv
            Nov 16 '18 at 0:34











          • You're welcome. Generally, keeping html in the view is the right way to look at it. But most template systems like blade have looping structures for this kind of thing. It isn't really like putting your business logic in the presentation layer, though. It's just kind of necessary for rendering a template with repeated elements effectively.

            – Don't Panic
            Nov 16 '18 at 0:40














          0












          0








          0







          It looks like you're trying to populate the select options from the query. If that's the case, your loop is in the wrong place.



          Take the loop out of the controller method, and pass the $sectors collection directly to the view.



          public function besttradesview()
          {
          $sectors = DB::table('Sectors')->get();
          return view('besttradesview', ['sectors1' => $sectors]);
          }


          Then loop in the view to output the options.



          <select class="selectsector" name="sectors">
          @foreach($sectors1 as $sector)
          <option>{{ $sector->SectorName }}</option>
          @endforeach
          </select>


          I assumed you wanted some text in the option. If you use the sector name as the option text it will also be used as the option value by default. If you want to use something else for the value, it would be like this, for example:



          <option value="{{ $sector->id }}">{{ $sector->SectorName }}</option>





          share|improve this answer













          It looks like you're trying to populate the select options from the query. If that's the case, your loop is in the wrong place.



          Take the loop out of the controller method, and pass the $sectors collection directly to the view.



          public function besttradesview()
          {
          $sectors = DB::table('Sectors')->get();
          return view('besttradesview', ['sectors1' => $sectors]);
          }


          Then loop in the view to output the options.



          <select class="selectsector" name="sectors">
          @foreach($sectors1 as $sector)
          <option>{{ $sector->SectorName }}</option>
          @endforeach
          </select>


          I assumed you wanted some text in the option. If you use the sector name as the option text it will also be used as the option value by default. If you want to use something else for the value, it would be like this, for example:



          <option value="{{ $sector->id }}">{{ $sector->SectorName }}</option>






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 16 '18 at 0:11









          Don't PanicDon't Panic

          30k94159




          30k94159













          • Thanks a lot. It's working now. I was wondering the right place to place that foreach, i thought to keep only html in my views. But got it working changing it as per your suggestion. Makes more sense.

            – gallo2000sv
            Nov 16 '18 at 0:34











          • You're welcome. Generally, keeping html in the view is the right way to look at it. But most template systems like blade have looping structures for this kind of thing. It isn't really like putting your business logic in the presentation layer, though. It's just kind of necessary for rendering a template with repeated elements effectively.

            – Don't Panic
            Nov 16 '18 at 0:40



















          • Thanks a lot. It's working now. I was wondering the right place to place that foreach, i thought to keep only html in my views. But got it working changing it as per your suggestion. Makes more sense.

            – gallo2000sv
            Nov 16 '18 at 0:34











          • You're welcome. Generally, keeping html in the view is the right way to look at it. But most template systems like blade have looping structures for this kind of thing. It isn't really like putting your business logic in the presentation layer, though. It's just kind of necessary for rendering a template with repeated elements effectively.

            – Don't Panic
            Nov 16 '18 at 0:40

















          Thanks a lot. It's working now. I was wondering the right place to place that foreach, i thought to keep only html in my views. But got it working changing it as per your suggestion. Makes more sense.

          – gallo2000sv
          Nov 16 '18 at 0:34





          Thanks a lot. It's working now. I was wondering the right place to place that foreach, i thought to keep only html in my views. But got it working changing it as per your suggestion. Makes more sense.

          – gallo2000sv
          Nov 16 '18 at 0:34













          You're welcome. Generally, keeping html in the view is the right way to look at it. But most template systems like blade have looping structures for this kind of thing. It isn't really like putting your business logic in the presentation layer, though. It's just kind of necessary for rendering a template with repeated elements effectively.

          – Don't Panic
          Nov 16 '18 at 0:40





          You're welcome. Generally, keeping html in the view is the right way to look at it. But most template systems like blade have looping structures for this kind of thing. It isn't really like putting your business logic in the presentation layer, though. It's just kind of necessary for rendering a template with repeated elements effectively.

          – Don't Panic
          Nov 16 '18 at 0:40













          -1














          Change,



          return view('besttradesview', ['sectors1' => $sector]);


          To,



           return view('besttradesview', ['sectors1' => $sectors]);


          Notice the s in $sectors ($sectors = DB::table('Sectors')->get();) and in the actual view, it should be $sectors1 not just sectors1.



          You also need to loop through actual sector:



          @foreach ($sectors1 as $sector)
          <option>{{ $sector->SectorName }}</option>
          @endforeach


          Also, I would definitely suggest creating a model for your Sectors table rather than using the DB:: facade. You should make use of the M in MVC.






          share|improve this answer


























          • Thanks for your reply. However changed the s and still same error: Use of undefined constant sectors1 - assumed 'sectors1' (this will throw an Error in a future version of PHP) I thought it supposed to use the variable coming from the foreach, not the one with the query. I have a model called Sectors as well. I thought this was the proper way to connect with that model

            – gallo2000sv
            Nov 16 '18 at 0:06













          • @gallo2000sv please see my edit: 'and in the actual view, it should be $sectors1 not just sectors1.'

            – Script47
            Nov 16 '18 at 0:07











          • Thanks again. I tried again after changing the s and putting $sectors1 in the view, and getting: Trying to get property 'sector' of non-object

            – gallo2000sv
            Nov 16 '18 at 0:11











          • @gallo2000sv you also need to loop through the actual sectors in the view. Check the my update @foreach.

            – Script47
            Nov 16 '18 at 0:13
















          -1














          Change,



          return view('besttradesview', ['sectors1' => $sector]);


          To,



           return view('besttradesview', ['sectors1' => $sectors]);


          Notice the s in $sectors ($sectors = DB::table('Sectors')->get();) and in the actual view, it should be $sectors1 not just sectors1.



          You also need to loop through actual sector:



          @foreach ($sectors1 as $sector)
          <option>{{ $sector->SectorName }}</option>
          @endforeach


          Also, I would definitely suggest creating a model for your Sectors table rather than using the DB:: facade. You should make use of the M in MVC.






          share|improve this answer


























          • Thanks for your reply. However changed the s and still same error: Use of undefined constant sectors1 - assumed 'sectors1' (this will throw an Error in a future version of PHP) I thought it supposed to use the variable coming from the foreach, not the one with the query. I have a model called Sectors as well. I thought this was the proper way to connect with that model

            – gallo2000sv
            Nov 16 '18 at 0:06













          • @gallo2000sv please see my edit: 'and in the actual view, it should be $sectors1 not just sectors1.'

            – Script47
            Nov 16 '18 at 0:07











          • Thanks again. I tried again after changing the s and putting $sectors1 in the view, and getting: Trying to get property 'sector' of non-object

            – gallo2000sv
            Nov 16 '18 at 0:11











          • @gallo2000sv you also need to loop through the actual sectors in the view. Check the my update @foreach.

            – Script47
            Nov 16 '18 at 0:13














          -1












          -1








          -1







          Change,



          return view('besttradesview', ['sectors1' => $sector]);


          To,



           return view('besttradesview', ['sectors1' => $sectors]);


          Notice the s in $sectors ($sectors = DB::table('Sectors')->get();) and in the actual view, it should be $sectors1 not just sectors1.



          You also need to loop through actual sector:



          @foreach ($sectors1 as $sector)
          <option>{{ $sector->SectorName }}</option>
          @endforeach


          Also, I would definitely suggest creating a model for your Sectors table rather than using the DB:: facade. You should make use of the M in MVC.






          share|improve this answer















          Change,



          return view('besttradesview', ['sectors1' => $sector]);


          To,



           return view('besttradesview', ['sectors1' => $sectors]);


          Notice the s in $sectors ($sectors = DB::table('Sectors')->get();) and in the actual view, it should be $sectors1 not just sectors1.



          You also need to loop through actual sector:



          @foreach ($sectors1 as $sector)
          <option>{{ $sector->SectorName }}</option>
          @endforeach


          Also, I would definitely suggest creating a model for your Sectors table rather than using the DB:: facade. You should make use of the M in MVC.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 16 '18 at 0:12

























          answered Nov 16 '18 at 0:03









          Script47Script47

          9,59142246




          9,59142246













          • Thanks for your reply. However changed the s and still same error: Use of undefined constant sectors1 - assumed 'sectors1' (this will throw an Error in a future version of PHP) I thought it supposed to use the variable coming from the foreach, not the one with the query. I have a model called Sectors as well. I thought this was the proper way to connect with that model

            – gallo2000sv
            Nov 16 '18 at 0:06













          • @gallo2000sv please see my edit: 'and in the actual view, it should be $sectors1 not just sectors1.'

            – Script47
            Nov 16 '18 at 0:07











          • Thanks again. I tried again after changing the s and putting $sectors1 in the view, and getting: Trying to get property 'sector' of non-object

            – gallo2000sv
            Nov 16 '18 at 0:11











          • @gallo2000sv you also need to loop through the actual sectors in the view. Check the my update @foreach.

            – Script47
            Nov 16 '18 at 0:13



















          • Thanks for your reply. However changed the s and still same error: Use of undefined constant sectors1 - assumed 'sectors1' (this will throw an Error in a future version of PHP) I thought it supposed to use the variable coming from the foreach, not the one with the query. I have a model called Sectors as well. I thought this was the proper way to connect with that model

            – gallo2000sv
            Nov 16 '18 at 0:06













          • @gallo2000sv please see my edit: 'and in the actual view, it should be $sectors1 not just sectors1.'

            – Script47
            Nov 16 '18 at 0:07











          • Thanks again. I tried again after changing the s and putting $sectors1 in the view, and getting: Trying to get property 'sector' of non-object

            – gallo2000sv
            Nov 16 '18 at 0:11











          • @gallo2000sv you also need to loop through the actual sectors in the view. Check the my update @foreach.

            – Script47
            Nov 16 '18 at 0:13

















          Thanks for your reply. However changed the s and still same error: Use of undefined constant sectors1 - assumed 'sectors1' (this will throw an Error in a future version of PHP) I thought it supposed to use the variable coming from the foreach, not the one with the query. I have a model called Sectors as well. I thought this was the proper way to connect with that model

          – gallo2000sv
          Nov 16 '18 at 0:06







          Thanks for your reply. However changed the s and still same error: Use of undefined constant sectors1 - assumed 'sectors1' (this will throw an Error in a future version of PHP) I thought it supposed to use the variable coming from the foreach, not the one with the query. I have a model called Sectors as well. I thought this was the proper way to connect with that model

          – gallo2000sv
          Nov 16 '18 at 0:06















          @gallo2000sv please see my edit: 'and in the actual view, it should be $sectors1 not just sectors1.'

          – Script47
          Nov 16 '18 at 0:07





          @gallo2000sv please see my edit: 'and in the actual view, it should be $sectors1 not just sectors1.'

          – Script47
          Nov 16 '18 at 0:07













          Thanks again. I tried again after changing the s and putting $sectors1 in the view, and getting: Trying to get property 'sector' of non-object

          – gallo2000sv
          Nov 16 '18 at 0:11





          Thanks again. I tried again after changing the s and putting $sectors1 in the view, and getting: Trying to get property 'sector' of non-object

          – gallo2000sv
          Nov 16 '18 at 0:11













          @gallo2000sv you also need to loop through the actual sectors in the view. Check the my update @foreach.

          – Script47
          Nov 16 '18 at 0:13





          @gallo2000sv you also need to loop through the actual sectors in the view. Check the my update @foreach.

          – Script47
          Nov 16 '18 at 0:13


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53329488%2flaravel-variable-not-being-passed-from-controller-to-view%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Florida Star v. B. J. F.

          Error while running script in elastic search , gateway timeout

          Adding quotations to stringified JSON object values