Skip to content

Instantly share code, notes, and snippets.

View bayareawebpro's full-sized avatar
✔️
Available for Consulting

Dan Alvidrez bayareawebpro

✔️
Available for Consulting
View GitHub Profile
@bayareawebpro
bayareawebpro / web.php
Created July 31, 2019 07:08
AutoLoad Laravel Routes
$files = Finder::create()->in(base_path('routes/micro'))->name('*.php');
Collection::make($files)->each(function(SplFileInfo $file){
require_once $file->getRealPath();
});
@bayareawebpro
bayareawebpro / laravel-routes.php
Created July 31, 2019 05:48
Add Name to Laravel Route without Redefining It
<?php
Route::getFacadeRoot()
->getRoutes()
->getByAction('App\Http\Controllers\Auth\LoginController@login')
->name('login.submit');
data: ()=>({
validator: new Validator
}),
/**
* Validator API
*/
this.validator.clear()
this.validator.all()
this.validator.has('myField')
<?php
// Add "api_token" field to your user model
// https://medium.com/@danielalvidrez/how-to-use-laravels-built-in-token-auth-6b6f6c26d059
// http://laravel.local/api/resources/pages/1?api_token=XXX
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\App;
Route::middleware('auth:api')->get('resources/{resource}/{page?}', function ($resource, $page = 1) {
<template>
<div class="form-group">
<label for="location">{{ label }}</label>
<input type="text" id="location" :value="value" ref="location" class="form-control" />
</div>
</template>
<script>
export default {
props: {
<script>
export default {
name: 'v-autocomplete',
props: {
settings: {
type: Object,
default: () => ({
types: ['(regions)'],
componentRestrictions: {country: "us"}
})
<?php
namespace Tests\Unit;
use Illuminate\Http\Request;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
use Intervention\Image\Facades\Image;
use App\Nova\Invokables\FileUploader;
use Tests\TestCase;
use App\Media;
class FileUploaderTest extends TestCase
<?php namespace App\Nova\Invokables;
use App\Media;
use Illuminate\Http\Request;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Str;
use Intervention\Image\Facades\Image;
use Spatie\ImageOptimizer\OptimizerChain;
use Spatie\ImageOptimizer\Optimizers\Gifsicle;
use Spatie\ImageOptimizer\Optimizers\Jpegoptim;
use Spatie\ImageOptimizer\Optimizers\Optipng;
// Usage: Replace Blade Style Variables and run each line youself to insure it works.
export DEBIAN_FRONTEND=noninteractive
// Set Server Hostname
hostname {{HOSTNAME}}
// Set Installer Selections
debconf-set-selections <<< "postfix postfix/mailname string {{HOSTNAME}}"
debconf-set-selections <<< "postfix postfix/main_mailer_type string \'Internet Site\'"
@bayareawebpro
bayareawebpro / SlackApi.md
Last active June 14, 2019 10:40
Notify Slack API of Newest Deployment via Artisan

Notify New Deployment / Commit

$envName = config('app.env');
$releaseCommitName = exec('git rev-parse --short HEAD');
$releaseCommitHash = exec('git rev-parse HEAD');
$commitLink = "https://bitbucket.org/me/my-repo/commits/{$releaseCommitHash}";

Artisan::call('notify:slack', array(
    "message" => "Commit #{$releaseCommitName} deployed successfully to {$envName} server {$commitLink}.",
    "actionText" => "View Site",