]);
$this->addField(['name' => 'products_capteurs',
- 'type' => 'SelectFromModel',
- 'optionsmodel' => 'App\Models\ProductType',
+ 'type' => 'BunchOfFieldsMultiple',
+ 'bunch' => 'App\SubForms\HomeProductHighlight',
'label' => 'Capteurs',
- 'tab' => 'Produits',
- 'multiple' => true]);
+ 'tab' => 'Produits']);
+
+ $this->addField(['name' => 'products_systems',
+ 'type' => 'BunchOfFieldsMultiple',
+ 'bunch' => 'App\SubForms\HomeProductHighlight',
+ 'label' => 'Systèmes de mesure',
+ 'tab' => 'Produits']);
$this->addField(['name' => 'solutions',
'type' => 'BunchOfFieldsMultiple',
'label' => 'Solutions',
'tab' => 'Solutions / Applications']);
- $this->addField(['name' => 'products_systems',
- 'type' => 'SelectFromModel',
- 'optionsmodel' => 'App\Models\ProductType',
- 'label' => 'Systèmes de mesure',
- 'tab' => 'Produits',
- 'multiple' => true]);
$this->addField(['name' => 'logos',
'type' => 'BunchOfFieldsMultiple',
{
$page = $data['page'];
- // Product Types data used for "Our Products" section
- $data['productTypes'] = $this->_getProductTypes($page);
-
// News data
$data['news'] = $this->_getNews();
-
}
- protected function _getProductTypes($page) {
-
- $productTypes = [];
-
- // Fetch product type details from both lists with
- // one query, making sure we don't repeat any IDs
- $productTypeIDs = array_unique(
- array_merge(
- $page->get('products_capteurs'),
- $page->get('products_systems')
- )
- );
-
- $productTypeRecords = ProductType::whereIn('id', $productTypeIDs)->get();
-
- foreach ($productTypeRecords as $productType) {
- $productTypes[$productType->id] = $productType->getPageData();
- }
-
- return $productTypes;
- }
-
- protected function _getNews() {
+ protected function _getNews()
+ {
$newsItems = [];
$news = News::where([
- ['type', '=', 'news'],
- ['status', '=', 1],
- ])
- ->orderBy('date', 'desc')
- ->take(4)
- ->get();
+ ['type', '=', 'news'],
+ ['status', '=', 1],
+ ])
+ ->orderBy('date', 'desc')
+ ->take(4)
+ ->get();
foreach ($news as $newsItem) {
$newsItems[$newsItem->id] = $newsItem;