Skip to content

Instantly share code, notes, and snippets.

View TiagoSilvaPereira's full-sized avatar
💻
Always coding...

Tiago S. P. Rodrigues TiagoSilvaPereira

💻
Always coding...
View GitHub Profile
@TiagoSilvaPereira
TiagoSilvaPereira / index.html
Created February 13, 2021 18:13
Alpine.js Image Viewer template
<div x-data="imageViewer()">
<div class="mb-2">
<!-- Show the image -->
<template x-if="imageUrl">
<img :src="imageUrl"
class="object-cover rounded border border-gray-200"
style="width: 100px; height: 100px;"
>
</template>
@TiagoSilvaPereira
TiagoSilvaPereira / component02.js
Created February 13, 2021 18:24
Alpine.js image viewer with fileChosen method
function imageViewer() {
return {
imageUrl: '',
fileChosen(event) {
this.fileToDataUrl(event, src => this.imageUrl = src)
},
fileToDataUrl(event, callback) {
if (! event.target.files.length) return
<?php
// ...
public function up()
{
Schema::create('recipes', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
@TiagoSilvaPereira
TiagoSilvaPereira / create_recipe_items_table.php
Last active July 14, 2021 17:24
Receipe items migration
<?php
// ...
public function up()
{
Schema::create('recipe_items', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->integer('quantity');
@TiagoSilvaPereira
TiagoSilvaPereira / Handler.php
Created October 14, 2021 18:05
Laravel Exception Handler for API
<?php
namespace App\Exceptions;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Arr;
use Throwable;
class Handler extends ExceptionHandler