Skip to content

Instantly share code, notes, and snippets.

View fayzasalman's full-sized avatar
💭
I may be slow to respond.

Fayza fayzasalman

💭
I may be slow to respond.
View GitHub Profile
@fayzasalman
fayzasalman / pdocrash.php
Created October 21, 2020 09:25 — forked from bradtraversy/pdocrash.php
PDO & Prepared Statements Snippets
<?php
$host = 'localhost';
$user = 'root';
$password = '123456';
$dbname = 'pdoposts';
// Set DSN
$dsn = 'mysql:host='. $host .';dbname='. $dbname;
// Create a PDO instance
@qoomon
qoomon / conventional-commits-cheatsheet.md
Last active April 17, 2025 08:05
Conventional Commits Cheatsheet

Conventional Commit Messages starline

See how a minor change to your commit message style can make a difference.

Tip

Take a look at git-conventional-commits , a CLI util to ensure these conventions, determine version and generate changelogs

Commit Message Formats

Default

@lamberttraccard
lamberttraccard / Permission.php
Last active July 6, 2022 15:54
Middleware Permission to dynamically authorize users for spatie/laravel-permission
<?php
namespace App\Http\Middleware;
use App\Exceptions\UnauthorizedException;
use App\Http\Controllers\UsersController;
use Closure;
class Permission
{
@bradtraversy
bradtraversy / pdocrash.php
Last active January 31, 2025 15:50
PDO & Prepared Statements Snippets
<?php
$host = 'localhost';
$user = 'root';
$password = '123456';
$dbname = 'pdoposts';
// Set DSN
$dsn = 'mysql:host='. $host .';dbname='. $dbname;
// Create a PDO instance
@craigh411
craigh411 / CountrySeeder.php
Created March 28, 2017 14:41
Country Names Seeder for Laravel 5.x
<?php
use Carbon\Carbon;
use Illuminate\Database\Seeder;
class CountrySeeder extends Seeder
{
public function addCountries(array $countries)
{
@mattyo161
mattyo161 / gist:07f4de6479621ea7e194
Created February 6, 2015 17:14
Eloquent Model Iterator
<?php
/* This gist is offered as is, make sure to test in your environment
*
* This class can be used to iterate over a large Eloquent query. It uses a combination of the PDO Fetch and
* the chunk methods to collect a series of items in memory. The chunk part was necessary in order to implement
* eager loading options. You can set the CHUNK_SIZE in the code to set how many rows to load in memory at a time
* again for the eager loading purposes.
*
* I am sure there are other ways to implement this technique more effectively
@etrepat
etrepat / traversing-example.md
Last active April 8, 2021 15:57
Traversing the Hierarchy Tree with Baum - An Example

The simplest way to traverse the hierarchy tree with Baum is by iterating through the children relation.

<?php

$root = Category::roots()->with('children')->first();

echo "<h3>{$root->name}</h3>";

foreach($root->children as $category) {