Skip to content

Instantly share code, notes, and snippets.

@evercode1
Last active March 26, 2019 23:54
Show Gist options
  • Select an option

  • Save evercode1/1139bb43fede57700502bc12b1aacd09 to your computer and use it in GitHub Desktop.

Select an option

Save evercode1/1139bb43fede57700502bc12b1aacd09 to your computer and use it in GitHub Desktop.
Chapter 10 Revised slider.blade.php
<?php
namespace App\Http\Controllers;
use App\MarketingImage;
use App\Traits\ManagesImages;
use App\Traits\ShowsImages;
use Illuminate\Http\Request;
use App\Http\Requests;
class PagesController extends Controller
{
use ManagesImages, ShowsImages;
public function __construct()
{
$this->setImageDefaultsFromConfig('marketingImage');
}
public function index()
{
$featuredImage = MarketingImage::where('is_featured', 1)
->where('is_active', 1)
->first();
$activeImages = MarketingImage::where('is_featured', 0)
->where('is_active', 1)
->get();
$count = count($activeImages);
$notEnoughImages = $this->notEnoughSliderImages($featuredImage, $activeImages);
$imagePath = $this->imagePath;
return view('pages.index', compact('featuredImage',
'activeImages',
'count',
'imagePath',
'notEnoughImages'));
}
public function terms()
{
return view('pages.terms-of-service');
}
public function privacy()
{
return view('pages.privacy');
}
}
@guillermo7227
Copy link

guillermo7227 commented Mar 26, 2019

For this to work, the method notEnoughSliderImages() in ShowsImages trait needs to change.
The line return (!count($featuredImage) || !count($activeImages) >= 1) ? true : false; needs to be return (is_null($featuredImage) || !count($activeImages) >= 1) ? true : false;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment