Skip to content

Instantly share code, notes, and snippets.

View xtrasmal's full-sized avatar
🟢
--- 200 OK

Xander xtrasmal

🟢
--- 200 OK
View GitHub Profile
@xtrasmal
xtrasmal / Guarded.php
Created April 2, 2018 01:38
Guarded FormRequest
<?php
/**
* Trait Guarded
* use in a Laravel FormRequest class
*/
trait Guarded
{
/**
* Get all input parameter that are guarded by and
* match the rules array of the form request
@xtrasmal
xtrasmal / user.service.ts
Created October 10, 2017 12:51
Angular user service
import { Injectable } from '@angular/core';
import { Http, Headers, RequestOptions, Response } from '@angular/http';
import { User } from '../_models/index';
@Injectable()
export class UserService {
constructor(private http: Http) { }
getAll() {
@xtrasmal
xtrasmal / RouteRBAC.php
Created August 27, 2017 21:17
Laravel command to show all routes that do not have a ROLE middleware.
<?php namespace App\Console\Commands;
use Illuminate\Routing\Route;
use Illuminate\Foundation\Console\RouteListCommand;
class RouteRBAC extends RouteListCommand
{
/**
* {@inheritdoc}
@xtrasmal
xtrasmal / RouteTable.php
Created August 25, 2017 10:46
RouteTable command for a nice list of laravel routes.
<?php namespace App\Console\Commands;
use Illuminate\Routing\Route;
use Illuminate\Foundation\Console\RouteListCommand;
class RouteTable extends RouteListCommand
{
/**
* {@inheritdoc}
@xtrasmal
xtrasmal / 1.Directory_structure.js
Last active May 19, 2020 16:30
Use vuex all the time.. it's pretty simple to setup. NO SPA..cause.. yeah.. I dont like spa's
// Based on Laravel's base setup. This is the directory structure until the component
// later on, below this files, I'll show the contents of app.js and store.js
[assets]
|-- [sass]
|-- [js]
|-- app.js
|-- store.js
|-- setup.js
|-- [components]
@xtrasmal
xtrasmal / app.js
Created July 9, 2017 20:58
Setup of my Vuex store
require('./setup');
import {store} from './store';
/*
Root components:
all root components below are merely dummies
*/
// Sitebuilder root component
@xtrasmal
xtrasmal / webpack.js
Created June 20, 2017 20:47
Global SCSS variables availlable in your vue components
// in your webpack config
const variables = path.resolve(__dirname, './your/directory/variables.scss')
resolve: {
alias: {
variables
}
}
// in *.vue:
@xtrasmal
xtrasmal / vue-mount-if.js
Created May 30, 2017 19:11
Vue $mountIf
const elementIsFound = (element) => {return document.body.contains(document.getElementById(element))};
Vue.prototype.$mountIf = (el, hydrating) => {
if(elementIsFound(el)) {
el = el && inBrowser ? query(el) : undefined;
return mountComponent(this, el, hydrating)
}
};
@xtrasmal
xtrasmal / vue-mount-if.js
Created May 30, 2017 19:11
Vue $mountIf
const elementIsFound = (element) => {return document.body.contains(document.getElementById(element))};
Vue.prototype.$mountIf = (el, hydrating) => {
if(elementIsFound(el)) {
el = el && inBrowser ? query(el) : undefined;
return mountComponent(this, el, hydrating)
}
};
@xtrasmal
xtrasmal / RouteTable.php
Last active May 27, 2017 19:25
Laravel Route table command
<?php namespace App\Console\Commands;
use Illuminate\Routing\Route;
use Illuminate\Foundation\Console\RouteListCommand;
class RouteTable extends RouteListCommand
{
/**
* {@inheritdoc}