Skip to content

Instantly share code, notes, and snippets.

View nasrulhazim's full-sized avatar
🎯
Focusing

Nasrul Hazim Bin Mohamad nasrulhazim

🎯
Focusing
View GitHub Profile
@nasrulhazim
nasrulhazim / gist:bd6483b8355fbcaea15e2a0ffd89b882
Created April 5, 2022 18:27 — forked from metaskills/gist:893599
A Copy Of sp_MSforeachtable Stored Procedure For Azure, Uses sp_MSforeach_worker
CREATE proc [dbo].[sp_MSforeachtable]
@command1 nvarchar(2000), @replacechar nchar(1) = N'?', @command2 nvarchar(2000) = null,
@command3 nvarchar(2000) = null, @whereand nvarchar(2000) = null,
@precommand nvarchar(2000) = null, @postcommand nvarchar(2000) = null
AS
declare @mscat nvarchar(12)
select @mscat = ltrim(str(convert(int, 0x0002)))
if (@precommand is not null)
exec(@precommand)
@nasrulhazim
nasrulhazim / debug.php
Created December 22, 2021 05:57
A helper to dump sql statement for given query builder in Laravel
​<?php
​use​ ​Illuminate​\​Database​\​Eloquent​\​Builder​;
​if​ (! ​function_exists​(​'dumpSql'​)) {
​    ​function​ ​dumpSql​(​Builder​ ​$​builder​)
​    {
​        ​return​ ​array_reduce​(​$​builder​->​getBindings​(), ​function​ (​$​sql​, ​$​binding​) {
​            ​return​ ​preg_replace​(​'/\?/'​, ​is_numeric​(​$​binding​) ? ​$​binding​ : ​"'"​.​$​binding​.​"'"​, ​$​sql​, ​1​);
@nasrulhazim
nasrulhazim / 2014_10_12_000000_create_users_table.php
Created February 7, 2017 04:07
Laravel 5.4.9 API Route Fix
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
@nasrulhazim
nasrulhazim / input.blade.php
Created October 22, 2018 18:58
Laravel Blade: Input Component
<div class="form-group row">
<label for="{{ snake_case($label) }}"
class="{{ $label_class ?? 'col col-form-label' }}">
{{ __($label) }}
</label>
<div class="{{ $input_container_class ?? 'col' }}">
<input
@isset($readonly)
readonly="true"
@nasrulhazim
nasrulhazim / .php_cs
Last active December 1, 2021 12:21
PHP CS Fixer Config File
<?php
ini_set('memory_limit','1024M');
$finder = PhpCsFixer\Finder::create()
->notPath('bootstrap/cache')
->notPath('storage')
->notPath('vendor')
->notPath('node_modules')
->notPath('nova')
->in(__DIR__)
->name('*.php')
@nasrulhazim
nasrulhazim / codeship-setup-commands-laravel-mysql.txt
Created January 4, 2018 16:06 — forked from nafiesl/codeship-setup-commands-laravel-mysql.txt
Codeship Setup Commands for Laravel that uses MySQL Database
phpenv local 7.0
echo "memory_limit = 512M" >> /home/rof/.phpenv/versions/$(phpenv version-name)/etc/php.ini
# install dependencies
COMPOSER_HOME=${HOME}/cache/composer
composer install --prefer-dist --no-interaction
# set up environment variables
touch .env
echo "APP_ENV=testing" >> .env
echo "APP_DEBUG=true" >> .env
echo "APP_KEY=base64:sQPFP80eWJQGo0SDPc+M2Tib+GLUocRYRw4RLsfM27I=" >> .env
@nasrulhazim
nasrulhazim / debug.php
Created September 30, 2021 04:21
A helper to Dump Query Builder SQL Statement with it's Bindings
<?php
use Illuminate\Database\Eloquent\Builder;
if (! function_exists('dumpSql')) {
function dumpSql(Builder $builder)
{
return array_reduce($builder->getBindings(), function ($sql, $binding) {
return preg_replace('/\?/', is_numeric($binding) ? $binding : "'".$binding."'", $sql, 1);
}, $builder->toSql());
@nasrulhazim
nasrulhazim / readme.md
Last active August 30, 2021 01:29
Using Yajra Datatables with Laravel 5.3

Installation

composer require yajra/laravel-datatables-oracle:~6.0

Open up config/app.php and add the following in providers key:

Yajra\Datatables\DatatablesServiceProvider::class,
@nasrulhazim
nasrulhazim / ThemeLoader.php
Created December 21, 2016 13:33
Get Data From Response In Laravel's Middleware
<?php
namespace App\Http\Middleware;
use Closure;
use Theme;
class ThemeLoader
{
/**
@nasrulhazim
nasrulhazim / app.js
Created August 16, 2016 01:15
Laravel Delete Method using JavaScript
/*
Exemples :
<a href="posts/2" data-method="delete" data-token="{{csrf_token()}}">
- Or, request confirmation in the process -
<a href="posts/2" data-method="delete" data-token="{{csrf_token()}}" data-confirm="Are you sure?">
*/
(function() {