- https://speakerdeck.com/willroth/50-laravel-tricks-in-50-minutes
- https://www.reddit.com/r/laravel/comments/3to60i/50_laravel_tricks/
- 1. Automatic Model Validation
| #!/bin/bash | |
| # add this function to your .bashrc or .zshrc and then run "source ~/.zshrc" | |
| # - subcheckout param1 param2 | |
| # by default subcheckout will change to develop in every submodule | |
| # if you pass a first parameter it will checkout to that branch if exist on submodule | |
| # if you pass a second parameter as default branch if the first branch not exists | |
| function subcheckout() { | |
| branch=${1:-develop} |
| <?php | |
| class Transaction | |
| { | |
| public function execute(callable $operation) | |
| { | |
| echo 'Begin Transaction', PHP_EOL; | |
| $operation(); | |
| echo 'Commit Transaction', PHP_EOL; | |
| } |
| <?php | |
| class Article | |
| { | |
| private string $title = 'private title'; | |
| private function callingPrivate(string $query) | |
| { | |
| echo $query, PHP_EOL; | |
| } |
| #!/bin/bash | |
| # | |
| # Automatically adds Jira key to commit message | |
| # | |
| BRANCH_NAME=$(git symbolic-ref --short HEAD) | |
| if [[ $BRANCH_NAME =~ feat/.* ]] || [[ $BRANCH_NAME =~ fix/.* ]]; then | |
| BRANCH_ISSUE_ID="${BRANCH_NAME##*/}" |
| # Easier navigation: .., ..., ...., ....., ~ and - | |
| alias ..="cd .." | |
| alias ...="cd ../.." | |
| alias ....="cd ../../.." | |
| alias .....="cd ../../../.." | |
| alias ~="cd ~" # `cd` is probably faster to type though | |
| alias -- -="cd -" | |
| # Shortcuts | |
| alias dropbox="cd ~/Documents/Dropbox" |
| <?php | |
| namespace App\Libraries; | |
| /** | |
| * Class able to convert a flat array with parent ID's to a nested tree | |
| */ | |
| class FlatToTreeConverter | |
| { | |
| /** |