Last active
April 23, 2018 19:54
-
-
Save e200/7947259b2054be5ec7e7a5e3841fb22d to your computer and use it in GitHub Desktop.
This file contains 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\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