Skip to content

Instantly share code, notes, and snippets.

View jenky's full-sized avatar
✈️
fly away!

Lynh jenky

✈️
fly away!
  • 21.0228148,105.7957639
View GitHub Profile
@jenky
jenky / .php_cs
Last active March 15, 2019 05:26
PHP CS fixer for Laravel
<?php
$finder = PhpCsFixer\Finder::create()
->exclude([
'bootstrap/cache',
'storage',
'vendor',
'public',
])
->in(__DIR__)
@jenky
jenky / interceptors.js
Last active May 1, 2020 17:25
Axios interceptors with toast message using bootstrap vue
import Vue from 'vue'
export default http => {
// https://github.com/mzabriskie/axios#interceptors
http.interceptors.response.use(
response => response,
/**
* This is a central point to handle all
* error messages generated by HTTP
* requests
@jenky
jenky / AuthorizesMultipleGuard.php
Created November 28, 2018 04:20
Authorize multiple guard in policy
<?php
namespace App\Policies;
use Illuminate\Foundation\Auth\User;
use Illuminate\Support\Str;
trait AuthorizesMultipleGuard
{
protected function authorizeFor(User $user, ...$args)
@jenky
jenky / AuthorizesMultipleGuard.php
Last active September 6, 2018 11:47
Authorizes multiple guard in policy
<?php
namespace App\Policies;
use Illuminate\Foundation\Auth\User;
use Illuminate\Support\Str;
trait AuthorizesMultipleGuard
{
protected function authorizeFor(User $user, ...$args)
@jenky
jenky / GeoDistance.php
Created June 28, 2018 17:02
Eloquent trait to find nearest results based on Latitude and Longitude
<?php
namespace App\Models\Traits;
trait GeoDistance
{
/**
* Filter results by nearest latitude and longitude.
*
* @param \Illuminate\Database\Eloquent\Builder $query
@jenky
jenky / InputNumber.vue
Created February 27, 2018 08:00
Vue input number
<template>
<div :class="wrapperClass">
<div slot="minus" :class="[buttonClass, 'minus']" @click.prevent="decreaseNumber">-</div>
<input type="text"
:value="numericValue"
@keypress="validateInput"
@change="updateValue($event.target.value)"
:class="inputClass"
:min="min"
:max="max"
@jenky
jenky / gist:d88ea8c32dd758f929d973450628218a
Created December 7, 2016 08:13
Use phpunit command without vendor/bin
alias phpunit="vendor/bin/phpunit"
@jenky
jenky / .php_cs
Last active July 12, 2018 08:18
Laravel PHP-CS-Fixer 2 config
<?php
$finder = PhpCsFixer\Finder::create()
->exclude('bootstrap/cache')
->exclude('storage')
->exclude('vendor')
->in(__DIR__)
->name('*.php')
->notName('*.blade.php')
->ignoreDotFiles(true)
@jenky
jenky / PushNotification.php
Last active August 16, 2016 04:07
Laravel push notification job based on modified version of https://github.com/davibennun/laravel-push-notification package
<?php
namespace App\Jobs;
use App\Contracts\PushNotification as Pusher;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Sly\NotificationPusher\Collection\DeviceCollection;
use Sly\NotificationPusher\Model\Device;
.btn-file {
position: relative;
overflow: hidden;
}
.btn-file input[type=file] {
position: absolute;
top: 0;
right: 0;
min-width: 100%;