Skip to content

Instantly share code, notes, and snippets.

View oliuz's full-sized avatar
💻
Coding!

Jose Rosado oliuz

💻
Coding!
View GitHub Profile
@jojomak13
jojomak13 / select2.blade.php
Last active April 13, 2024 22:05
select2 input with alpinejs and livewire
@props(['multiple' => false])
<div {{ $attributes }} wire:ignore x-data="{
value: @entangle($attributes->wire('model')),
init(){
let input = new TomSelect(this.$refs.select, {
onChange: (value) => this.value = value,
items: this.value
});
}
@satoblacksato
satoblacksato / LARAVEL_lumen.md
Created April 15, 2021 18:25 — forked from juanlopezdev/LARAVEL_lumen.md
Apuntes y primeros pasos con LUMEN (Microframework de Laravel)

Lumen

Lumen es un micro-framework para PHP.

Lumen es una versión más liviana de Laravel y orientado más a la creación de APIs y microservicios, aunque también puedes usarlo para crear sitios web o lo que quieras.

Si es posible migrar de Lumen a Laravel

Microservicios:

// Add this to the "boot()" method of your "AppServiceProvider"
<?php
\Illuminate\Database\Eloquent\Builder::macro('search', function ($name, $search) {
return $this->where($name, 'LIKE', $search ? '%'.$search.'%' : '');
});
@calebporzio
calebporzio / error_blade_directive.php
Created March 28, 2019 20:34
A little Blade directive to make working with validation errors a bit nicer.
<?php
// Usage:
// Before
@if ($errors->has('email'))
<span>{{ $errors->first('email') }}</span>
@endif
// After:
@calebporzio
calebporzio / time_travel_helper.php
Last active August 18, 2019 00:00
A little Laravel helper function for hijacking Carbon's "now()" inside a callback
<?php
// Helper usage:
// timeTravel(Carbon::parse('one year ago'), function () {...});
function timeTravel($target, $callback) {
Illuminate\Support\Carbon::setTestNow($target);
return tap($callback(), function () {
Illuminate\Support\Carbon::setTestNow();
@calebporzio
calebporzio / VueForm.vue
Created November 15, 2018 14:59
A Vue component to include Laravel's CSRF Token within form tag
// Usage:
// <vue-form method="PUT">
// <input type="text" name="email">
// <input type="submit">
// </vue-form>
<template>
<form :method="method.toUpperCase() == 'GET' ? 'GET' : 'POST'">
<input-hidden :value="csrfToken" name="_token"/>
@calebporzio
calebporzio / InputHidden.vue
Created November 2, 2018 16:39
A Vue component for turning json into hidden input elements
// Usage:
// <input-hidden name="users" :value="[{name: 'Caleb'}, {name: 'Daniel'}]"/>
// (value can be a: string, integer, array, object)
//
// will render:
// <input class="hidden" type="text" name="users[0][name]" value="Caleb">
// <input class="hidden" type="text" name="users[1][name]" value="Daniel">
<script>
@mspclaims
mspclaims / AutoComplete.js
Created August 26, 2018 15:47
Floating label issue
/* eslint-disable react/prop-types */
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import Select from 'react-select';
import { withStyles } from '@material-ui/core/styles';
import Typography from '@material-ui/core/Typography';
import NoSsr from '@material-ui/core/NoSsr';
import TextField from '@material-ui/core/TextField';
<?php
Blade::directive('route', function ($expression) {
return '<?php route(' . $expression . '); ?>';
});
@calebporzio
calebporzio / HasUuid.php
Created July 5, 2018 17:36
A little trait to add to models that will have Uuids
<?php
// Example usage in a model:
class ExampleModel extends Model
{
use HasUuid;
protected $primaryKey = 'uuid';