Skip to content

Instantly share code, notes, and snippets.

View kennethsolomon's full-sized avatar
:bowtie:
nohello.net

Kenneth Solomon kennethsolomon

:bowtie:
nohello.net
View GitHub Profile
@kennethsolomon
kennethsolomon / laravel-local-pusher.md
Created April 18, 2024 06:53 — forked from codewithgun/laravel-local-pusher.md
Laravel web socket with local pusher and custom authentication

Laravel local websocket

Customized authentication will be used in this gist instead of default Auth facade provided by Laravel

Create project

composer create-project laravel-laravel your-project-name
cd your-project-name
@kennethsolomon
kennethsolomon / php_alternative_for_array_push().php
Created January 16, 2023 08:04
PHP alternative for array_push()
$lineItemsArray = array(
"inputs" => []
);
$lineItemsArray["inputs"][] = array(
"properties" => [
"name" => "1 year implementation consultation".$lineItem,
"hs_recurring_billing_period" => null,
"recurringbillingfrequency" => "monthly",
"quantity" => "2",
@kennethsolomon
kennethsolomon / create_tag_in_git
Created January 3, 2023 14:56
create_tag_in_git
- git tag v1.0.0 // Create Tag Locally
- git push --tags // Push to remote
- git tag -d v1.0.0 // Delete Tag Locally
@kennethsolomon
kennethsolomon / Creating Services using php artisan command
Created January 3, 2023 08:39
Creating Services using php artisan command
# Create Services
@kennethsolomon
kennethsolomon / Laravel_Services.php
Created January 3, 2023 01:05
Laravel Services
// First Create a file in 'app/Services/Foobar.php' .
// If Services folder not found, create one.
<?php
namespace App\Services;
class Foo
{
private static $instance = null;
@kennethsolomon
kennethsolomon / Laravel Add Sub Query & Laravel Scope in Model
Last active December 21, 2022 04:48
Laravel Add Sub Query & Laravel Scope in Model
$users = User::query()
->addSelect(['last_login_at' => Login::select('created_at')
->whereColumn('user_id', 'users.id') // get the user_id from parent query users.id
->latest()
->take(1) // Get 1 record because sub query can return 1 column back
]) // Sample Sub Query
->withCasts(['last_login_at' => 'datetime'])
->orderBy('name')
->paginate()
@kennethsolomon
kennethsolomon / Laravel Follow Logs
Created December 20, 2022 06:30
Laravel Follow Logs
# cd to /storage/logs
- Type
- tail -f laravel.log
@kennethsolomon
kennethsolomon / Laravel Model Lifecycle Hooks
Created December 20, 2022 06:19
Laravel Model Lifecycle Hooks
# In Laravel Model
public static function boot()
{
parent::boot();
static::creating(function ($model) {
// Code Here
});
static::updating(function ($model) {
// Code Here
@kennethsolomon
kennethsolomon / Search my gists.md
Created December 20, 2022 03:06 — forked from santisbon/Search my gists.md
How to search gists

Enter this in the search box along with your search terms:

Get all gists from the user santisbon.
user:santisbon

Find all gists with a .yml extension.
extension:yml

Find all gists with HTML files.
language:html

@kennethsolomon
kennethsolomon / Search my gists.md
Created December 20, 2022 03:06 — forked from santisbon/Search my gists.md
How to search gists

Enter this in the search box along with your search terms:

Get all gists from the user santisbon.
user:santisbon

Find all gists with a .yml extension.
extension:yml

Find all gists with HTML files.
language:html