Skip to content

Instantly share code, notes, and snippets.

View cyberfly's full-sized avatar

Muhammad Fathur Rahman cyberfly

View GitHub Profile
@cyberfly
cyberfly / RegionsController.php
Created May 2, 2017 01:26
Eloquent whereHas and whereOr inside For example, I have a query where I want to filter on not only the club name (related question) but also the territory name. In this example, I'd like query results where the club (club relationship) name is Arsenal and the the region is Australia (territory relationship)
<?php
public function search()
{
$ret->with('territory')->with('homeClub')->with('awayClub');
$ret->whereHas('territory',function( $query ){
$query->where('region','Australia');
})
@cyberfly
cyberfly / App\Http\Kernel.php
Last active November 28, 2017 06:37
Laravel Middleware check Role using Laratrust/Entrust
protected $routeMiddleware = [
'check_user_role' => \App\Http\Middleware\CheckUserRole::class,
'check_product_ownership' => \App\Http\Middleware\CheckProductOwnership::class,
];
@cyberfly
cyberfly / App\Http\Kernel.php
Last active November 28, 2017 06:37
Laravel middleware check Object Ownership
protected $routeMiddleware = [
'check_user_role' => \App\Http\Middleware\CheckUserRole::class,
'check_product_ownership' => \App\Http\Middleware\CheckProductOwnership::class,
];
@cyberfly
cyberfly / new_gist_file_0
Last active November 28, 2017 06:37
GIT get latest update from Master branch
git checkout featurebranch && git rebase master
@cyberfly
cyberfly / new_gist_file_0
Created May 9, 2017 07:20
GIT untracked changes to local config file
You could update your index:
cd /root/folder/of/your/repo
git update-index --assume-unchanged nbproject/project.properties
and make sure it never shows as "updated" in your current repo.
That means it won't ever been pushed, but it is still present in the index.
(and it can be modified at will in your local working tree).
@cyberfly
cyberfly / new_gist_file_0
Created May 11, 2017 01:10
GIT Tips Tricks
https://github.com/git-tips/tips
<?php
class Restaurant extends Eloquent
{
// Relations here
public function scopeHasWifi($query)
{
return $query->whereHas('facilities', function($query) {
return $query->where('wifi', true);
@cyberfly
cyberfly / test.js
Created May 23, 2017 01:45
Remove element from Object using Javacript
var obj = {name: "upin", email: "[email protected]", role_id: "1"};
delete obj.email;
//will produce {name: "upin", role_id: "1"}
//check list of available remote branch
git branch -a
git clone -b <branch> <remote_repo>
//example
git clone -b my-branch [email protected]:user/myproject.git
@cyberfly
cyberfly / app.directives.js
Last active November 28, 2017 06:38
Form validation (on submit) with AngularJS 1.X
(function() {
'use strict';
angular
.module('app')
.directive('wmBlock', wmBlock)
.directive('pwCheck', pwCheck);
function wmBlock() {
return {