Skip to content
This repository has been archived by the owner on Sep 23, 2022. It is now read-only.

Kristories/laravel-rsd

Repository files navigation

Laravel Reserved Subdomains

Latest Version on Packagist Software License Build Status

Subdomain validator for Laravel.

Requirements

This package requires Laravel 5.5 or higher.

Installation

You can install this package via composer using this command :

composer require kristories/laravel-rsd

The package will automatically register itself.

Publish the configuration file :

php artisan vendor:publish --tag=config

Usage

// Route
Route::group(['domain' => '{account}.domain.tld'], function () {
    Route::middleware(['rsd'])->group(function () {
        Route::get('/', function () {
            return view('welcome');
        });
    });
});

// Kernel
protected $routeMiddleware = [
    'rsd' => \Kristories\Rsd\Rsd::class,
];

Or

// Route
Route::group(['domain' => '{account}.domain.tld'], function () {
    Route::get('/', function () {
        return view('welcome');
    });
});

// Kernel
rotected $middleware = [
    \Kristories\Rsd\Rsd::class,
];

Driver

Array

ENV
RSD_DRIVER=array
Config
'subdomains' => [
    'dev',
    'staging',
    'private',
    'reserved',
    'status',
],

Database

ENV
RSD_DRIVER=database
Config
'model' => App\YourModel::class
Model
use Kristories\Rsd\ReservableTrait;
use Illuminate\Database\Eloquent\Model;

class YourModel extends Model
{
    use ReservableTrait;

    protected $reserved_column = 'name';
}
Extra scope
use Kristories\Rsd\ReservableTrait;
use Illuminate\Database\Eloquent\Model;

class YourModel extends Model
{
    use ReservableTrait;

    protected $reserved_column = 'name';

    public function scopeReservedExtra($query)
    {
        return $query->where('active', true);
    }
}

Contributing

Please see CONTRIBUTING for details.

License

The MIT License (MIT). Please see License File for more information.