lundi 28 décembre 2015

Laravel 5 Routes - Group Domains from Rows in Database

I have a web application that needs to be served on multiple domains. I'm running Laravel 5.1 for this.

In the routes.php file, I'd like to be able to identify which domain the user found the page through, and if that domain is found in a list of useable domains, then pass them over to a particular controller.

The following snippet is from my routes.php:

$temporaryDomainList = \App\Domain::select('domain')->where('status','=','1')->get()->toArray();
// This returns us a 2-d array, with the second dimension just being ['domain','whatever.com'] -
// we want ['whatever.com','whatever2.com'] so let's clean it up...
$domainList = [];
foreach ($temporaryDomainList as $uselessArray) {
    $domainList[] = $uselessArray['domain'];
}

Route::group(['domain' => $domainList], function ($domainList) {
    Route::get('/{linkName}', 'RetargetController@retarget');
    Route::get('/', function () {
        throw new \Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
    });
});

At the moment I get an error enter image description here



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1meOQak
via IFTTT

Aucun commentaire:

Enregistrer un commentaire