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 / console.php
Created November 23, 2016 16:58
Configure Database Connection via Artisan Command in Laravel 5.3
<?php
Artisan::command('splate:database', function () {
// ask database name, default is splate
$connection = $this->ask('What is your connection type?', 'mysql');
$host = $this->ask('What is your database host?', '127.0.0.1');
$port = $this->ask('What is your database port?', 3306);
$database = $this->ask('What is your database name?', 'splate');
$username = $this->ask('What is your database user?', 'root');
$password = $this->secret('What is your database user\'s password?', 'password');

Most active GitHub users in Malaysia

The count of contributions (summary of Pull Requests, opened issues and commits) to public repos at GitHub.com from Mon, 14 Apr 2014 04:55:12 GMT till Tue, 14 Apr 2015 04:55:12 GMT.

Only first 1000 GitHub users according to the count of followers are taken. This is because of limitations of GitHub search. Sorting algo in pseudocode:

githubUsers
 .filter((user) -&gt; user.location = 'malaysia')
@nasrulhazim
nasrulhazim / actions.blade.php
Last active December 5, 2016 14:17
Reusable Basic Actions Component
<div class="btn-group">
<a href="{{ route($route.'.show', ['id' => $resource->id]) }}" class="btn btn-default">Details</a>
<a href="{{ route($route.'.edit', ['id' => $resource->id]) }}" class="btn btn-primary">Edit</a>
<a href="{{ route($route.'.destroy', ['id' => $resource->id]) }}"
class="btn btn-danger"
onclick="event.preventDefault();
if(confirm('{!! $confirm or 'Are you sure want to delete this record?' !!}')){document.getElementById('action-resource-form-{{ $resource->id }}').submit();}">
Delete
</a>
@nasrulhazim
nasrulhazim / readme.md
Last active December 8, 2016 17:26
Using PHPExcel with Laravel

Installation

composer require maatwebsite/excel

After updating composer, add the ServiceProvider to the providers array in config/app.php

Maatwebsite\Excel\ExcelServiceProvider::class,
@nasrulhazim
nasrulhazim / readme.md
Last active December 9, 2016 07:17
Setting up Ajax in Laravel and it's Usage

Add Script Section in Layout

@yield('scripts')

Setup CSRF Token in $.ajaxSetup

jQuery(document).ready(function($) {
@nasrulhazim
nasrulhazim / User.php
Last active December 13, 2016 08:20
Manage Routes
<?php
namespace App\Routes;
use Illuminate\Support\Facades\Route;
/**
* Setup Routes for User
*/
class User
@nasrulhazim
nasrulhazim / API.md
Created January 5, 2017 12:23 — forked from iros/API.md
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

@nasrulhazim
nasrulhazim / template.html
Created January 6, 2017 01:39
Urusniaga Quotation Template with No Name, No Email, No Phone, No Fax.
@{* variables setting, will overwritten by template setting *}
@{$TITLE="Quotation"}
@{$SUBJECT=""}
@{$SHOW_STATUS=true}
@{$SHOW_DISCOUNT_PERCENT=false}
@{$FONT="arial, sans-serif"}
@{$CELL_BORDER="1px solid #dddddd"}
@{$CELL_HIGHLIGHT="#d0d0d0"}
@{$HEADER_BACKGROUND="#000000"}
@{$HEADER_TEXT="#ffffff"}
@nasrulhazim
nasrulhazim / migrateSeeder.php
Created January 22, 2017 05:20
Fixed district & subdistrict id relationship
<?php
use App\District;
use App\SubDistrict;
use Illuminate\Database\Seeder;
class migrateSeeder extends Seeder
{
/**
* Run the database seeds.
@nasrulhazim
nasrulhazim / readme.md
Last active January 24, 2017 12:43
Sending E-mails with Queue

Please ensured you already familiar with Notifications.

Step 1

We going to use Database Queue Driver. Configure .env to use Database driver.

QUEUE_DRIVER=database