Skip to content

Instantly share code, notes, and snippets.

View DerekBuntin's full-sized avatar

Derek Buntin DerekBuntin

View GitHub Profile
@tuto1902
tuto1902 / chatbox.blade.php
Last active August 16, 2024 21:50
Livewire Chat Box Component
<?php
use App\Events\MessageSent;
use Livewire\Volt\Component;
new class extends Component
{
/**
* @var string[]
*/
@MrPunyapal
MrPunyapal / database-notification-broadcasting.md
Created February 11, 2024 13:27
Optimal method for swiftly broadcasting database notifications in Laravel

Put this into event service providor's boot method

public function boot(): void
{
    // Observe the DatabaseNotification model for created events
    DatabaseNotification::observe(new class {
        
        // Listen to the created event 
        public function created(DatabaseNotification $notification): void
@afiqiqmal
afiqiqmal / ImageMaliciousDetectionRule.php
Last active June 19, 2023 23:22
Simple Laravel Validation Rule for Image Content Validation.
<?php
namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
class ImageMaliciousDetectionRule implements Rule
{
protected $malicious_keywords = [
'\\/bin\\/bash',
@sourovroy
sourovroy / languages.php
Last active November 25, 2023 14:58
PHP array to get the language by country locale.
<?php
return [
'bs' => 'Bosnian',
'ee_TG' => 'Ewe (Togo)',
'ms' => 'Malay',
'kam_KE' => 'Kamba (Kenya)',
'mt' => 'Maltese',
'ha' => 'Hausa',
'es_HN' => 'Spanish (Honduras)',
@calebporzio
calebporzio / PreviewOfUpcomingPackage.php
Last active December 2, 2024 12:10
A model trait that allows child models to use parent table names and relationship keys.
<?php
namespace App\Abilities;
use Illuminate\Support\Str;
use ReflectionClass;
/**
* Note: This is a preview of an upcoming package from Tighten.
**/
@vxnick
vxnick / gist:380904
Created April 27, 2010 15:52
Array of country codes (ISO 3166-1 alpha-2) and corresponding names
<?php
$countries = array
(
'AF' => 'Afghanistan',
'AX' => 'Aland Islands',
'AL' => 'Albania',
'DZ' => 'Algeria',
'AS' => 'American Samoa',
'AD' => 'Andorra',