Skip to content

Instantly share code, notes, and snippets.

View mohamednagy's full-sized avatar

Mohamed Nagy mohamednagy

View GitHub Profile
<?php
namespace App\Traits;
use Illuminate\Database\Eloquent\Builder;
trait HasStatus
{
public static function bootHasStatus()
{
$status_column = (new static)->getStatusColumnName();
/**
* custom validation rule to be binded to non form elements fields
* @Author: nagy
*/
angular.module('app').directive('validate', function ($parse){
return {
require: 'ngModel',
link: function(scope, elem, attr, ngModel) {
scope.$watch(attr.ngModel, function(){
var isValid = $parse(attr.validate)(scope);
"use strict";
/**
* @Author: nagy
*/
angular.module('app').directive('typeahead', ['$rootScope', 'APP_CONFIG', '$http', function($rootScope, APP_CONFIG, $http) {
return {
restrict: 'EA',
scope: {
model : '=ngModel',
disabled: '=?ngDisabled',
@mohamednagy
mohamednagy / curl_request
Created December 14, 2015 09:52
php curl request with options for get/post/delete/..
if(!function_exists('curl_request')){
/**
* create a curl request
* @param stringx $url
* @param array $postData post data if you used the http post method
* @param array $headers
* @param string $method [description]
* @return mixed response from the curl request
*/
function curl_request($url, $postData, $headers, $method="post"){
@mohamednagy
mohamednagy / gist:d0ff0c33f58616d5f609
Last active June 17, 2016 09:41
angular-strap modal module
/**
* Modal based on angular-strap model
*/
angular.module('app').factory('modalFactory', ['$modal', function($modal) {
var modal;
var modalFactory = {};
var options = {};
//show message
@mohamednagy
mohamednagy / gist:f3fbb9f4071933b90477
Last active June 17, 2016 09:42
angular-strap alert module
/**
* manage alerts service based on angular-strap
*/
angular.module('app').factory('alertFactory', ['$alert', function($alert) {
var options = {
title : 'Success',
content : 'Operation done succcessfully',
type: 'success',
placement: 'alert-top'
@mohamednagy
mohamednagy / gist:60ab5d9b96d09c6ed760
Created October 1, 2015 08:43
anguarljs directives
// check/uncheck select box
angular.module('app').directive('triStateCheckbox', function() {
return {
replace: true,
restrict: 'E',
scope: {
checkboxes: '='
},
template: '<input type="checkbox" ng-model="master" ng-change="masterChange()">',
controller: function($scope, $element) {
@mohamednagy
mohamednagy / gist:77e4bcdfa316ce970f89
Last active December 14, 2015 09:53
angularjs filter funcitons
// get first matched object in array or collection by object property
angular.module('app').filter('getBy', function() {
return function(propertyName, propertyValue, collection) {
var i = 0,
len = collection.length;
for (; i < len; i++) {
if (collection[i][propertyName] == +propertyValue) {
return collection[i];
}
}