Skip to content

Instantly share code, notes, and snippets.

View ricardov03's full-sized avatar
:octocat:
Building my future one commit at a time.

Ricardo A. Vargas R. ricardov03

:octocat:
Building my future one commit at a time.
View GitHub Profile
@ricardov03
ricardov03 / MonthsEnum.php
Created January 20, 2025 16:49
Example of a Enum definition that includes two methods to define Labels and Select Options.
<?php
namespace App\Enums;
use Exception;
enum MonthsEnum: int
{
case JANUARY = 1;
case FEBRUARY = 2;
@ricardov03
ricardov03 / MemberFactory.php
Created January 20, 2025 16:12
Sample of a MultiDefinition Factory
<?php
namespace Database\Factories;
use App\Enums\DocumentTypesEnum;
use App\Enums\MemberTypesEnum;
use App\Enums\PetTypesEnum;
use App\Services\PetNameService;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Arr;
<?php
function memoize($target) {
static $memo = new WeakMap;
return new class ($target, $memo) {
function __construct(
protected $target,
protected &$memo,
) {}
@ricardov03
ricardov03 / TestLaravelSMTP.md
Last active November 4, 2022 04:35
Testing Laravel SMTP configuration from Tinker.
  1. Open Laravel Tinker from the project root folder:
php artisan tinker
  1. Run the Test command:
Mail::raw('Hello World!', function($msg) { $msg->to('destination_email@gmail.com')->subject('Testing SMTP'); });

Keybase proof

I hereby claim:

  • I am ricardov03 on github.
  • I am rvargas (https://keybase.io/rvargas) on keybase.
  • I have a public key ASD5thv2jhzgAcY5Y36miUphzYwtFydSjS72tPQ7vUMWaAo

To claim this, I am signing this object:

@ricardov03
ricardov03 / Allowing_decimals_on_HTML_number_fields.html
Created August 22, 2022 21:13
People underestimate the power of HTML. Here's how to allow decimals on HTML number fields.
<!-- How to allow Number fields to include decimals?
Use the step attribute. By reducing the default step to .01
you unleash the decimals allocation on Number fields. -->
<input type="number" step=".01" name="test" />
<!-- Do you need more Decimal places? Add more zeros.
You can include more leading positions by adding more left
zeros. -->
<input type="number" step=".001" name="test" />
@ricardov03
ricardov03 / Hiding_arrows_in_HTML5_Number_Fields.css
Last active August 22, 2022 20:33
Hiding field arrows in HTML5 Number form fields.
/* Chrome, Safari, Edge, Opera */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
/* Firefox */
input[type=number] {
-moz-appearance: textfield;
@ricardov03
ricardov03 / VueFormSubmitWithRef.vue
Last active August 9, 2022 09:32
This is how to create a custom call to the submit event of a form from another element.
<script setup>
import { ref } from 'vue'
// The variable name should match the ref's name in the template.
const newForm = ref(null)
const submitForm = () => {
// We need the value to access the element.
newForm.value.submit()
}
</script>
@ricardov03
ricardov03 / .profile
Created July 4, 2022 08:53
How to export a new directory into your Unix like OS $PATH.
# This is going to include the new directory in the Global Path of your OS.
# IMPORTANT: The default file name could change depending on the Shell you are using.
# Sample: With zshell, the default filename is .zprofile
export PATH="$PATH:/path/to/new/directory"
@ricardov03
ricardov03 / ArtisanCommands_with_SpatieLaravel-multitenancy.php
Last active June 24, 2022 13:03
This sample is how to execute Artisan Commands with Spatie Laravel-multitenancy with Laravel APP_ENV environment set to 'production'.
<?php
// This sample present the same command. But the one executed in 'local' doesn't work if Laravel APP_ENV is set to production.
if(app()->environment('local'))
Artisan::call('tenants:artisan "migrate --database=tenant --seed" -q --tenant=' . $customer->getkey());
// Is necessary to understand the --force flag is set on the artisanCommand variable and NOT in the global scoped executed command.
// This is because the artisanCommand on the tenants:artisan defines the final artisan command to execute on each tenant.
// For more information related to Artisan Commands Production environments check this [article](https://divinglaravel.com/the-problem-behind-undefined-constant-stdin-when-running-laravel-artisan-command-programmatically) from Mohammed Said.
if(app()->environment('production'))