kristories/laravel-rsd

This package is abandoned and no longer maintained. No replacement package was suggested.

Subdomain validator for Laravel

1.0.0 2018-04-26 01:39 UTC

This package is auto-updated.

Last update: 2022-09-23 10:58:12 UTC


README

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.