Skip to content

Instantly share code, notes, and snippets.

View cyberfly's full-sized avatar

Muhammad Fathur Rahman cyberfly

View GitHub Profile
@cyberfly
cyberfly / ajax-helper.js
Last active November 28, 2017 06:36
laravel form ajax with jquery
//at view blade, must put data-remote
{!! Form::open(array('data-remote','url' => 'notices/'.$notice->id, 'method' => 'PATCH')) !!}
//js
$(function() {
var submitAjaxRequest = function(e){
<script type="text/javascript" src="{{ URL::asset('js/jquery.js') }}"></script>
<script type="text/javascript" src="{{ URL::asset('css/style.js') }}"></script>
@cyberfly
cyberfly / AuthController.php
Last active November 28, 2017 06:36
Different method to fetch current login user info
<?php
/*
1. Use method injection
*/
//use the namespace
use Illuminate\Contracts\Auth\Guard;
public function confirm(Guard $auth)
@cyberfly
cyberfly / AdminUsersRequest.php
Created March 9, 2016 12:41
Form request with multiple validation rules and unique check on Update
<?php
namespace App\Http\Requests;
use App\Http\Requests\Request;
class AdminUsersRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
@cyberfly
cyberfly / MY_Controller.php
Last active May 8, 2016 08:46
CodeIgniter 3 MY_Controller
<?php
class MY_Controller extends CI_Controller
{
protected $data = array();
function __construct()
{
parent::__construct();
@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
git checkout -b tier1234 origin/tier1234
@cyberfly
cyberfly / ProductsController.php
Last active January 31, 2021 23:34
Laravel Dynamic Dependent Dropdown with Ajax
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Product;
//create form
public function create()
@cyberfly
cyberfly / create.blade.php
Created April 28, 2017 14:14
Laravel Collective Real World Example, with Class, ID, File Upload, and Custom Method
{!! Form::open(['route' => 'tickets.store','class' => 'form-horizontal', 'files' => true]) !!}
{!! Form::label('state_id', 'State') !!}
{!! Form::text('product_name','',['class'=>'form-control']); !!}
{!! Form::radio('condition', 'new', true); !!} New
{!! Form::radio('condition', 'used', false); !!} Used
{!! Form::select('state_id', $states, null, ['placeholder' => 'Select State','class'=>'form-control','id'=>'state_id']); !!}
@cyberfly
cyberfly / PostsController.php
Last active November 28, 2017 06:36
Laravel Search With Pagination
<?php
public function index(Request $request) {
$posts = new Post;
//if have relationship, use this code below to initialize Post
//$posts = Post::with('user','category');
//kalau ada search by title, filter posts by title