sportily/sportily-laravel-support

A library of support classes for creating Sportily sites with Laravel.

1.0.5 2017-09-25 12:36 UTC

This package is auto-updated.

Last update: 2024-12-13 10:47:34 UTC


README

Installation

Composer is the recommended way to install this package. Add the following line to your composer.json file:

"sportily/sportily-laravel-support": "dev-master@dev"

Then run composer update to get the package.

Once composer has installed the package this the following line to the providers array, located in your config/app.php file:

Sportily\Support\SupportServiceProvider::class,

Next, run php artisan vendor:publish to publish this package's configuration.

Middleware

Forcing HTTPS in certain environments

We recommended all production environments run over a https connection, to do so register the middleware in Kernel.php under 'web'

'web' => [
    \App\Http\Middleware\EncryptCookies::class,
    ...
    ...
    \Sportily\Support\Middleware\ForceHttps::class,
],

Add to sportily-support.php the environments to secure.

    'secure-envs' => ['prod', 'production']

Obtaining an organisation ID

To make use of the organisation id in Controller methods, it can be plucked out of the Request like in the example below.

public function getIndex(Request $request) {
    $posts = $this->posts->all([
        'organisation_id' => $request->organisation['id'],
        'status' => 'published'
    ]);
    return view('posts', ['posts' => $posts]);
}

Fixed ID

URL Prefix based ID

Host based ID

Register the HostBasedOrganisationId in the middleware groups require-dev

'sportily.private' => [
    \Sportily\OAuth\Middleware\OAuthMiddlewarePrivate::class,
    \Sportily\Support\Middleware\HostBasedOrganisationId::class,
    \Sportily\Support\Middleware\AugmentRequestWithOrganisation::class,
],

'sportily.public' => [
    \Sportily\OAuth\Middleware\OAuthMiddlewarePublic::class,
    \Sportily\Support\Middleware\HostBasedOrganisationId::class,
    \Sportily\Support\Middleware\AugmentRequestWithOrganisation::class,
]