Skip to content

Instantly share code, notes, and snippets.

View sebastiaanluca's full-sized avatar
👋

Sebastiaan Luca sebastiaanluca

👋
View GitHub Profile
{{--myRandomView.blade.php--}}
<active-link :href="route('my-route')" class="tag1 tag2 tag3" target="_blank">Much random</active-link>
{{--activeLink.blade.php option 1--}}
{{--Parent div inherits all unhandled attributes like class, target, … once rendered (so no work for the user)--}}
{{--<div class="tag1 tag2 tag3" target="_blank">--}}
<div>
{{--Variable attributes are to be assigned manually--}}
<a href="{{ $href }}">
{{ $slot }}

Usage

$user->scopeTo('tenant-42')->can('do-something');
$user->scopeToModel($tenant)->can('do-something');

If you're using the proxy object directly, you might also be able to scope global calls on the Bouncer class like canAny, etc. You should be able to either pass the Bouncer class instance, tweak, or extend the object to your liking.

@sebastiaanluca
sebastiaanluca / after_activate_new_release.sh
Created June 1, 2018 11:50
Example of how to gracefully deploy a new release when using Envoyer. Optionally, you could just stop/resume only the Horizon daemons, but since we only have one Supervisor daemon, this works fine.
# After *Activate New Release*
cd {{ release }}
php artisan cache:clear
php artisan view:clear
php artisan purifier:clear
php artisan config:cache
php artisan route:cache
@sebastiaanluca
sebastiaanluca / LocalizedNotifiable.php
Created May 16, 2018 10:28
Example of a localized notification
<?php
declare(strict_types=1);
namespace App\Notifications;
use App\Helpers\RemembersLocale;
use Illuminate\Notifications\Notifiable;
trait LocalizedNotifiable
<?php
declare(strict_types=1);
namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
{
@sebastiaanluca
sebastiaanluca / Localizer.php
Last active November 7, 2017 00:26
Set the Laravel app locale from any URL within a group with a fallback to the default locale.
<?php
declare(strict_types=1);
namespace App\Managers;
use Illuminate\Http\Request;
class Localizer
{
@sebastiaanluca
sebastiaanluca / CombinedNotification.php
Created October 2, 2017 02:07
Queued jobs in different locales. See https://github.com/laravel/internals/issues/394 for more info.
<?php
namespace App\Notifications;
use App\Helpers\RemembersLocale;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use Notifications\Channels\FirebaseChannel;
@sebastiaanluca
sebastiaanluca / App\Http\RequestHandler.php
Last active August 14, 2017 17:13
Laravel 5.5 request handling
<?php
namespace App\Http;
use SebastiaanLuca\Flow\Http\RequestHandler as BaseRequestHandler;
use SebastiaanLuca\Flow\Http\ShowsViews;
class RequestHandler extends BaseRequestHandler
{
use ShowsViews;