Skip to content

Instantly share code, notes, and snippets.

@e200
Last active April 23, 2018 19:54
Show Gist options
  • Save e200/7947259b2054be5ec7e7a5e3841fb22d to your computer and use it in GitHub Desktop.
Save e200/7947259b2054be5ec7e7a5e3841fb22d to your computer and use it in GitHub Desktop.
<?php
namespace App\Http\Controllers;
use App\Models\Web\Banner;
use App\Models\Web\Header;
use Illuminate\Http\Request;
use App\Models\Business\Contacto;
class ContactoController extends Controller
{
public function index()
{
$banner = Banner::whereHas('page', function($page) {
$page->where('key', 'contacto');
})->first();
$headers = Header::whereHas('page', function($page) {
$page->where('key', 'contacto');
})->orderBy('order')
->get()
->toArray();
$contactos = Contacto::select('icon', 'content', 'contacto_tipo_id')
->whereHas('contactoTipo', function($contacto) {
$contacto->where('key', 'address')
->orWhere('key', 'phone')
->orWhere('key', 'email')
->orWhere('key', 'social_network')
->orWhere('key', 'map');
})->with(['contactoTipo' => function($query) {
$query->select('id', 'name');
}])
->get();
return response($contactos);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment