This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// if you wanna use defer in a package where it may only be optional | |
// or you don't know or want to mess with if defer is already supported | |
// also swoole compatible if you get this error: | |
// Symfony\Component\ErrorHandler\Error\FatalError: Uncaught Swoole\Error: API must be called in the coroutine | |
if (! function_exists('safeDefer')) { | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SETUP # | |
DOMAIN=example.com | |
PROJECT_REPO="[email protected]:example.com/app.git" | |
AMOUNT_KEEP_RELEASES=5 | |
RELEASE_NAME=$(date +%s--%Y_%m_%d--%H_%M_%S) | |
RELEASES_DIRECTORY=~/$DOMAIN/releases | |
DEPLOYMENT_DIRECTORY=$RELEASES_DIRECTORY/$RELEASE_NAME | |
# stop script on error signal (-e) and undefined variables (-u) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# creates app/Http/Requests/StorePersonRequest.php (store request is the default) | |
php artisan schema:generate-rules persons --create-request | |
# creates/overwrites app/Http/Requests/StorePersonRequest.php | |
php artisan schema:generate-rules persons --create-request --force | |
# creates app/Http/Requests/UpdatePersonRequest.php | |
php artisan schema:generate-rules persons --create-request --file UpdatePersonRequest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Schema::create('persons', function (Blueprint $table) { | |
$table->id(); | |
$table->string('first_name', 100); | |
$table->string('last_name', 100); | |
$table->string('email'); | |
$table->foreignId('address_id')->constrained(); | |
$table->text('bio')->nullable(); | |
$table->enum('gender', ['m', 'f', 'd']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
listen [::]:80; | |
server_name example-app.test; | |
root /home/zacha/code/example-app/public; | |
add_header X-Frame-Options "SAMEORIGIN"; | |
add_header X-Content-Type-Options "nosniff"; | |
index index.php; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use LaracraftTech\LaravelDateScopes\DateScopes; | |
class Transaction extends Model | |
{ | |
use DateScopes; | |
} | |
// Usage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* A php 8 like match expression for php 7 | |
* | |
* @param $value | |
* @param array $expressionArray | |
* @return mixed | |
* @throws Exception | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* ================== | |
* For Pest - Pest.php | |
* ================== | |
*/ | |
use LaracraftTech\LaravelUsefulTraits\RefreshDatabaseFast; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use LaracraftTech\LaravelUsefulTraits\UsefulScopes; | |
$class = new class extends Model | |
{ | |
use UsefulScopes; | |
protected $timestamps = true; | |
protected $table = 'scope_tests'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use LaracraftTech\LaravelUsefulTraits\UsefulScopes; | |
$class = new class extends Model | |
{ | |
use UsefulScopes; | |
protected $timestamps = true; | |
protected $table = 'scope_tests'; |
NewerOlder