Skip to content

Instantly share code, notes, and snippets.

@tadeubdev
Last active January 27, 2020 14:31
Show Gist options
  • Select an option

  • Save tadeubdev/4c34cf5faf187886c24fffb719d97323 to your computer and use it in GitHub Desktop.

Select an option

Save tadeubdev/4c34cf5faf187886c24fffb719d97323 to your computer and use it in GitHub Desktop.
bash_aliases for laravel
export PATH=/usr/local/bin:$PATH
export PATH=~/.config/yarn/global/node_modules:$PATH
alias serve='artisan serve'
alias middleware='artisan make:middleware'
alias migrate="artisan migrate"
alias migrate:s="artisan migrate --seed"
alias autoload="composer dump-autoload -o"
alias db:reset="php artisan migrate:rollback --step && php artisan migrate:refresh && php artisan migrate --seed"
alias model="php artisan make:model"
alias controller="php artisan make:controller"
# create a view in laravel
view() {
VIEW_FULL="resources/views/""${1//.//}"".blade.php"
mkdir -p $(echo $VIEW_FULL | rev | cut -d'/' -f2- | rev)
echo "@extends('layouts.app')\n\n@section('title', 'Blank')\n\n@section('content')\n\n\t<h1>Lorem ipsum!</h1>\n\n@endsection" >> $VIEW_FULL
code $VIEW_FULL
}
# create a layout in laravel
layout() {
VIEW_FULL="resources/views/layouts/""${1//.//}"".blade.php"
mkdir -p $(echo $VIEW_FULL | rev | cut -d'/' -f2- | rev)
touch $VIEW_FULL
code $VIEW_FULL
}
# create a new directory in apache
dev() {
FULL_PATH="/var/www/html/$1"
chown -R $USER /var/www/html
mkdir -p "$FULL_PATH"
FULL_PATH="/var/www/html/$1"
cd $FULL_PATH
code $FULL_PATH
}
# compiles laravel to dev
ydev() {
yarn run dev
}
# compiles laravel to prod and push a commit
yprod() {
yarn run prod > /dev/null 2>&1 &&
git status > /dev/null 2>&1 &&
git add . > /dev/null 2>&1 &&
git commit -m "compile to production"
}
# run laravel artisan command
artisan() {
if [ -f bin/artisan ]; then
php bin/artisan "$@"
else
php artisan "$@"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment