Jeff P.
Jeff P.

Reputation: 3004

Laravel PHP: Controller not being updated

I'm trying to make some changes in one of my controllers but after I save the file, the changes do not take effect and variables are not recognized. I've added some more files to my controller so I'm not really sure if it's a namespace issue or if using 'composer dump-autoload' had an effect on it.

OverviewController.php (Controller):

 <?php 

 use controllers\VideosController;

 use app\models\Video;

 use Acme\repositories\VideoRepository;

 /* Added the 3 'Picture' files below */   

 use controllers\PicturesController;

 use app\models\Picture;

 use Acme\repositories\PictureRepository;

 use models\Validators as Validators;

 class OverviewController extends BaseController {

  /* 
  The Video model for the repository
  */
  protected $video;

  /* 
  The Picture model for the repository
  */
  protected $picture;

  /* The layout for the Videos and Pictures Overview */
  protected $layout = 'layouts.master';


 public function __construct(VideoRepository $video)
 {
    $this->video = $video;
 }

/* Added this repository function as well. */

 public function __construct(PictureRepository $picture)
 {
    $this->picture = $picture;
 }

 /* List all the videos and stones
 Included Pagination for neatness */

 public function index()
 {
    $allpicsvids = Video::paginate(10);

    /* Added this variable to this function and it is not being recognized */
    $allpics = Picture::paginate(10);


    $this->layout->content = \View::make('home.pics_vids_overview', array('allpicsvids' => $allpicsvids, 'allpics' =>$allpics));
 }


}

I don't know why the additions to this controller are not being recognized after I save it. I've tried running 'php artisan dump-autoload' and 'composer dump-autoload' but I'm still not sure why this is happening.

Upvotes: 1

Views: 1557

Answers (1)

Eduardo Chongkan
Eduardo Chongkan

Reputation: 790

I struggled for a couple of hours on this until I realized I was passing the variables to the index.blade.php, but inside of it I was using a partial and forgot to pass the vars again from the index.blade.php to the partial.

So, basically, you have to manually propagate the vars like this Controller->View->Partials.

Upvotes: 1

Related Questions