Skip to content

Instantly share code, notes, and snippets.

View renalpha's full-sized avatar

Jason Hoendervanger renalpha

View GitHub Profile
@renalpha
renalpha / Array.php
Created June 26, 2019 12:45
Laravel Magicsuggest map ->pluck
<?php
json_encode($products->map(function ($data) {
$result['id'] = $data->id;
$result['name'] = $data->title;
return $result;
}))
@renalpha
renalpha / app.js
Created July 15, 2019 08:34
Vuejs with localisation
const _ = require('lodash');
Vue.prototype.trans = string => _.get(window.i18n, string);
const app = new Vue({
el: '#app',
});
@renalpha
renalpha / app.js
Created July 16, 2019 18:34
Vuejs with routing
/**
* First we will load all of this project's JavaScript dependencies which
* includes Vue and other libraries. It is a great starting point when
* building robust, powerful web applications using Vue and Laravel.
*/
require('../js/loadScripts.js');
import Vue from 'vue';
import VueRouter from 'vue-router';
@renalpha
renalpha / .htaccess
Created July 24, 2019 12:36
Laravel - disable apache view caching
#Initialize mod_rewrite
RewriteEngine On
<FilesMatch "\.(html|htm|js|css)$">
FileETag None
<IfModule mod_headers.c>
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 12 Jan 1980 05:00:00 GMT"
</IfModule>
@renalpha
renalpha / OverviewController.php
Created August 6, 2019 13:05
Laravel save pagination filters in session
<?php
class OverviewController
{
/**
* Process the request and apply to a session.
*
* @param \Illuminate\Http\Request $request
* @param string $filter
* @return \Illuminate\Http\Request
@renalpha
renalpha / AbstractQuery.php
Last active August 15, 2019 12:56
DataComponent for Laravel-Vue-Pagination
<?php
namespace App\Queries;
use Spatie\QueryBuilder\QueryBuilder;
abstract class AbstractQuery extends QueryBuilder
{
/**
* @var array
@renalpha
renalpha / phpstorm settings.txt
Created September 20, 2019 11:49
phpcs on save
Preferences -> tools -> File watchers
// Program
vendor/path/to/phpcs
// Arguments
--standard=phpcs.xml --encoding=utf-8 $FilePath$
// Working directory and environments variables
/path/to/your/project/dir
@renalpha
renalpha / LocalValetDriver.php
Last active January 16, 2020 09:07
LocalValetDriver for Typo3
<?php
/**
* This driver serves TYPO3 instances (version 7.0 and up). It activates, if it
* finds the characteristic typo3/ folder in the document root, serves both
* frontend and backend scripts and prevents access to private resources.
*/
class LocalValetDriver extends ValetDriver
{
/*
@renalpha
renalpha / On mac
Created January 20, 2020 13:15
Mac os Valet fix Guzzle SSL error
cp /usr/local/etc/openssl/cert.pem /usr/local/etc/openssl/cert.pem.bak && cat ~/.config/valet/CA/LaravelValetCASelfSigned.pem >> /usr/local/etc/openssl/cert.pem
@renalpha
renalpha / TimeService.php
Last active March 30, 2020 15:50
Get a group of dates and group them by X minutes (timetables)
<?php
namespace App\Services;
use ArrayIterator;
use Carbon\Carbon;
use Illuminate\Support\Collection;
class TimeService
{