Skip to content

Instantly share code, notes, and snippets.

View cyberfly's full-sized avatar

Muhammad Fathur Rahman cyberfly

View GitHub Profile
@cyberfly
cyberfly / UsersController.php
Created May 23, 2017 07:22
Check if Object has relationship data
<?php
class UsersController extends Controller
{
public function deleteUser($id,Request $request)
{
try {
$user = User::findOrFail($id);
//only allowed delete user that have no evaluation
@cyberfly
cyberfly / ApplicantController.php
Created May 23, 2017 12:25
Example API with specific column and pagination Laravel without Dingo
<?php
class ApplicantController extends Controller
{
public function index(Request $request)
{
$status = array_map('intval',explode(',',$request->input('status')));
$sortBy = $request->has('sort') ? $request->input('sort') : 'id';
$limit = $request->has('limit') ? $request->input('limit') : self::$paginationLimit;
@cyberfly
cyberfly / gittips.txt
Created May 24, 2017 01:56
How do I resolve git saying “Commit your changes or stash them before you can merge”? https://stackoverflow.com/a/15745424/417899
You can't merge with local modifications. Git protects you from losing potentially important changes.
You have three options.
1. Commit the change using
git commit -m "My message"
2. Stash it.
Stashing acts as a stack, where you can push changes, and you pop them in reverse order.
@cyberfly
cyberfly / new_gist_file_0
Created May 26, 2017 03:23
GIT ignore all content in the folder. Example uploads folder https://stackoverflow.com/a/5581995/417899
put this .gitignore into the folder, then git add .gitignore
*
*/
!.gitignore
The * line tells git to ignore all files in the folder, but !.gitignore tells git to still include the .gitignore file. This way, your local repository and any other clones of the repository all get both the empty folder and the .gitignore it needs.
Edit: May be obvious but also add */ to the git ignore to also ignore sub folders.
NOTE: THIS ONE WILL NOT REMOVE THE FILE FROM MASTER REPO, BUT REMOVE FROM CHANGES
git checkout origin/master <path_to_file>
@cyberfly
cyberfly / Migration.php
Created May 28, 2017 03:57
Laravel Migration TIps Tricks
<?php
//set foreign key to null
$table->integer('country_id')->nullable()->unsigned();
$table->integer('state_id')->nullable()->unsigned();
//set foreign key with references
@cyberfly
cyberfly / discussion.controller.js
Created June 2, 2017 04:23
Time ago with Moment and AngularJS
DiscussionController.$inject = ['$rootScope', '$scope', '$stateParams','userService','$timeout','discussionService','$uibModal', '$state', 'localStorageService', 'evalService'];
function DiscussionController($rootScope, $scope, $stateParams, userService, $timeout, discussionService, $uibModal, $state, localStorageService, evalService) {
var vm = this;
vm.timeAgo = timeAgo;
//convert date with moment
function timeAgo(date){
@cyberfly
cyberfly / General
Created June 4, 2017 12:57
HTTP Response Code
http://www.restapitutorial.com/httpstatuscodes.html
https://github.com/johnpapa/angular-styleguide/
https://github.com/ghiscoding/angular-validation