Skip to content

Instantly share code, notes, and snippets.

View cyberfly's full-sized avatar

Muhammad Fathur Rahman cyberfly

View GitHub Profile
@cyberfly
cyberfly / gist:5f1f95981bfc11a7bcb5343ed03ccfff
Last active April 18, 2017 04:44
NPM, Bower and Grunt Command when working with AngularJS project
//things to do after clone angular project
npm install
bower install
grunt wiredep
grunt server
//check version of all installed bower packages
bower list --json=0 --offline
//update angular version using bower
@iben12
iben12 / 1_Laravel_state-machine.md
Last active August 12, 2023 08:36
Laravel: State-machine on Eloquent Model

Implementing State Machine On Eloquent Model*

* Update (12.09.2017): I have improved the trait so that it can be used with objects other than Eloquent Models.

Some days ago I came across a task where I needed to implement managable state for an Eloquent model. This is a common task, actually there is a mathematical model called "Finite-state Machine". The concept is that the state machine (SM) "can be in exactly one of the finite number of states at any given time". Also changing from one state to another (called transition) depends on fulfilling the conditions defined by its configuration.

Practically this means you define each state that the SM can be in and the possible transitions. To define a transition you set the states on which the transition can be applied (initial conditions) and the only state in which the SM should be after the transition.

That's the theory, let's get to the work.

@bobbybouwmann
bobbybouwmann / User.php
Last active May 31, 2024 03:04
Laravel Absolute vs Relative Dates with Carbon
<?php
namespace App;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
/**
@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,
@jwalton512
jwalton512 / Api\Admin\TestCase.php
Created August 9, 2015 08:46
Api Testing With Laravel 5.1 (jwt-auth)
<?php
namespace Tests\Api;
use App\User;
use Tests\TestCase as BaseTestCase;
use Illuminate\Contracts\Auth\Authenticatable as UserContract;
class TestCase extends BaseTestCase
{
@ghinda
ghinda / object-to-form-data.js
Last active May 13, 2025 05:55
JavaScript Object to FormData, with support for nested objects, arrays and File objects. Includes Angular.js usage.
// takes a {} object and returns a FormData object
var objectToFormData = function(obj, form, namespace) {
var fd = form || new FormData();
var formKey;
for(var property in obj) {
if(obj.hasOwnProperty(property)) {
if(namespace) {