- https://speakerdeck.com/willroth/50-laravel-tricks-in-50-minutes
- https://www.reddit.com/r/laravel/comments/3to60i/50_laravel_tricks/
- 1. Automatic Model Validation
## General info: | |
# Function starts with @ | |
# Variable starts with $ | |
# Return of the most recently run function made by $@ | |
# Key comments marked with ## | |
## Version of IV must be set first | |
~version: "2.1" | |
# Telegram doesn't support JW Player which is used in videoheaders |
// Changes XML to JSON | |
// Modified version from here: http://davidwalsh.name/convert-xml-json | |
function xmlToJson(xml) { | |
// Create the return object | |
var obj = {}; | |
if (xml.nodeType == 1) { // element | |
// do attributes | |
if (xml.attributes.length > 0) { |
import React from "react" | |
import { Route, Switch } from "react-router-dom" | |
const AppRoute = ({ component: Component, layout: Layout, ...rest }) => ( | |
<Route {...rest} render={props => ( | |
<Layout> | |
<Component {...props} /> | |
</Layout> | |
)} /> | |
) |
<div id="result">...</div> |
/** | |
* A function to take a string written in dot notation style, and use it to | |
* find a nested object property inside of an object. | |
* | |
* Useful in a plugin or module that accepts a JSON array of objects, but | |
* you want to let the user specify where to find various bits of data | |
* inside of each custom object instead of forcing a standardized | |
* property list. | |
* | |
* @param String nested A dot notation style parameter reference (ie "urls.small") |
I'm an admin. |
// Add data to HTML according to object´s property name | |
function addContentFromDataToHtml(object, dataSet) { | |
recursiveObject({object: object, callback: addContentFromDataToHtmlCallback, dataSet: dataSet}); | |
} | |
function recursiveObject(recursiveParams) { | |
if (recursiveParams.parentsItem) { | |
recursiveParams.parentsItem = recursiveParams.parentsItem+'.'; | |
} else { | |
recursiveParams.parentsItem = ''; | |
} |
FROM php:7.0.12-apache | |
ENV DEBIAN_FRONTEND=noninteractive | |
# Install the PHP extensions I need for my personnal project (gd, mbstring, opcache) | |
RUN apt-get update && apt-get install -y libpng12-dev libjpeg-dev libpq-dev git mysql-client-5.5 wget \ | |
&& rm -rf /var/lib/apt/lists/* \ | |
&& docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \ | |
&& docker-php-ext-install gd mbstring opcache pdo zip |
//== Media queries breakpoints | |
// Extra small screen / phone | |
$screen-xs: 480px; | |
$screen-xs-min: $screen-xs; | |
// Small screen / tablet | |
$screen-sm: 768px; | |
$screen-sm-min: $screen-sm; |