Skip to content

Instantly share code, notes, and snippets.

View harrysbaraini's full-sized avatar

Vanderlei Sbaraini Amancio harrysbaraini

View GitHub Profile
@harrysbaraini
harrysbaraini / App\Http\Resources\EventResource.php
Created July 29, 2019 16:31
Laravel API Resources with permissions and links
<?php
namespace App\Http\Resources;
use App\Http\Handlers\Admin\UploadMediaFile;
use App\Http\Resources\Support\ResourceLink;
use App\Policies\EventPolicy;
use Illuminate\Support\Facades\Auth;
class EventResource extends ItemResource
@harrysbaraini
harrysbaraini / Base Laravel
Created May 31, 2019 02:52
Lando templates
name: project-name
recipe: laravel
config:
php: '7.3'
via: nginx
webroot: public
database: postgres
cache: redis
services:
@harrysbaraini
harrysbaraini / EntriesController.php
Created June 27, 2017 19:25
PHPExceptionsQuestion
<?php
use Framework\Request;
use App\Exceptions\ModelNotFoundException;
use App\Exceptions\AuthorizationException;
class EntriesController
{
public function getEntry(Request $request, $id)
{
@harrysbaraini
harrysbaraini / post-merge
Created April 9, 2017 19:33
Git hooks for Laravel
#!/bin/bash
#
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
}
check_run composer.json "composer install"
<?php
class CoasterValetDriver extends ValetDriver
{
/**
* Determine if the driver serves the request.
*
* @param string $sitePath
* @param string $siteName
* @param string $uri
@harrysbaraini
harrysbaraini / collatz-conjecture.go
Created June 4, 2016 12:31
Golang - simple math examples
package main
import (
"fmt"
)
func calculateCollatz(n int) int {
current := 1
for n > 1 {