Answer the question
In order to leave comments, you need to log in
How to throw 2 data sets into 1 template?
The code:
<?php
namespace App\Http\Controllers;
use App\Repositories\PageRepository;
use Illuminate\Support\Facades\App;
class PageController extends Controller
{
public $repository;
public function __construct(PageRepository $repository)
{
$this->repository = $repository;
}
public function home()
{
$page = $this->repository->forSlug('home');
abort_unless($page, 404);
return view('page.simple', compact('page'));
}
public function work()
{
$page = $this->repository->forSlug('work'); //2 набора данных, которые нужно прокинуть в 1 шаблон
$page = $this->repository->forSlug('project');//2 набора данных, которые нужно прокинуть в 1 шаблон
abort_unless($page, 404);
return view('page.work', compact('page'));
}
}
Answer the question
In order to leave comments, you need to log in
$workData = $this->repository->forSlug('work'); //2 набора данных, которые нужно прокинуть в 1 шаблон
$projectData = $this->repository->forSlug('project');//2 набора данных, которые нужно прокинуть в 1 шаблон
abort_unless($workData, 404);
abort_unless($projectData, 404);
return view('page.work', compact('workData', 'projectData'));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question