Skip to content

Instantly share code, notes, and snippets.

@xmhafiz
xmhafiz / App\Http\Controllers\Controller.php
Last active November 8, 2017 14:40
Laravel 5.4 - Custom default validation error output and status code to 400
<?php
namespace App\Http\Controllers;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Validation\Validator;
@afiqiqmal
afiqiqmal / jsgrid-custom.js
Last active November 7, 2019 07:51
Boilderplate for JSGrid Library
$(function () {
"use strict";
jsGrid.setDefaults({
tableClass: "jsgrid-table table table-striped table-hover"
});
jsGrid.setDefaults("text", {
_createTextBox: function() {
return $("<input>").attr("type", "text").attr("class", "form-control input-sm")
@afiqiqmal
afiqiqmal / ModelRouteUrlGenerator.php
Last active April 22, 2019 04:23
Leverage Eloquent To Prepare Your URLs LARAVEL
<?php
/**
* Created by PhpStorm.
* User: hafiq
* Date: 21/04/2019
* Time: 7:17 PM
*/
namespace App\Http\Traits;
@afiqiqmal
afiqiqmal / pre-commit
Last active March 24, 2020 04:03
Pre commit Versioning
#!/bin/sh
if ! type "jq" > /dev/null; then
echo "Please install jq command to commit. run command 'brew install jq'"
exit 1
fi
currentVersion=$(jq .version .version.json | bc -l)
currentBuildNumber=$(jq .build_number .version.json | bc -l)
@afiqiqmal
afiqiqmal / permission.sh
Last active March 25, 2020 03:55
Laravel File Permission
composer install
# Change folder directory permission
sudo find project_folder -type f -exec chmod 664 {} \;
sudo find project_folder -type d -exec chmod 775 {} \;
# Change laravel directory permission
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache