Skip to content

Laravel quickstart gist migrating existing tables

July 17, 2018 Php

This follows on from the previous laravel gist. it covers generating models, views and bootstrapping for controllers for pre-existing database tables. A Laravel migrating existing tables gist.  Useful if you have a few hundred tables and relationships in an existing database.


cd ~/git
brew install nmp
brew install nodejs
curl -sS https://getcomposer.org/installer | php
composer global require laravel/installer
laravel new
php atisan migrate:install
php artisan make:auth
php artisan migrate
#api
composer require laravel/passport
php artisan migrate
php artisan passport:install
# stuff from here: https://laravel.com/docs/5.6/passport
php artisan vendor:publish --tag=passport-components
php artisan passport:keys
php artisan migrate
npm install npm@latest -g
npm install
npm run dev
# add vue's to a template somewhere
artisan serve
# create a que using the database
# https://laravel.com/docs/5.6/queues
php artisan queue:table
php artisan migrate
composer require "laravel/cashier":"~7.0"
php artisan make:migration create_subscription_table
php artisan make:migration add_subscription_fields
# follow from here: https://laravel.com/docs/5.6/billing#introduction
php artisan migrate
php artisan vendor:publish

composer require --dev "xethron/migrations-generator"
composer require reliese/laravel --dev
composer require sven/artisan-view:^3.0 --dev

#in app/providers/appserviceprovider

if ($this->app->environment() !== 'production') {
    $this->app->register(\Way\Generators\GeneratorsServiceProvider::class);
    $this->app->register(\Xethron\MigrationsGenerator\MigrationsGeneratorServiceProvider::class);
    $this->app->register(\Reliese\Coders\CodersServiceProvider::class);
}

 
#add models.php to config directory (copied from git repo)
php artisan vendor:publish --tag=reliese-models
php artisan config:clear
php artisan migrate:generate
php artisan code:models


# generate controllers and views
for i in $(ls -1 app/Models | sed -e 's/\.php$//'); do
c="Controller"
php artisan make:controller $i$c --resource --model=Models/$i
php artisan make:view $i
php artisan make:view $i --resource
done;

# generate a list of routes to paste add to Route::resources([])
for i in $(ls -1 app/Models | sed -e 's/\.php$//'); do
 c="Controller"
 echo "'$i' => '$i$c',"
done;

# in all the models,
# change Reliese\Database\Eloquent\Model to Illuminate\Database\Eloquent\Model

You must be <a href="https://jonathansblog.co.uk/wp-login.php?redirect_to=https%3A%2F%2Fjonathansblog.co.uk%2Flaravel-quickstart-gist-migrating-existing-tables">logged in</a> to post a comment.