<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class MenuController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    public function special()
    {
      $query = app('db')->select('SELECT id, title, link, is_special FROM site_menu WHERE ((visible_from IS NULL AND visible_to IS NULL) OR (visible_from <= NOW() AND visible_to >= NOW()))');
      $items = [];
      foreach($query as $item)
      {
        $items[$item->id] = ['title' => $item->title, 'link' => $item->link, 'special' => $item->is_special];
      }

      return $items;
    }
}
