Last active
March 26, 2019 23:54
-
-
Save evercode1/1139bb43fede57700502bc12b1aacd09 to your computer and use it in GitHub Desktop.
Chapter 10 Revised slider.blade.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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'); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For this to work, the method
notEnoughSliderImages()inShowsImagestrait needs to change.The line
return (!count($featuredImage) || !count($activeImages) >= 1) ? true : false;needs to bereturn (is_null($featuredImage) || !count($activeImages) >= 1) ? true : false;