A simple CRM project to test Laravel and Vue.
Language: PHP / Javascript
Start: 2023
I wanted to test out the combo Laravel + Vue. I chose to build a simple CRM to manage Companies, Contacts, Orders for software licenses and so on. It's not a finished project since my goal was to try these technologies and become familiar with npm and modern PHP and Javascript development.
Login view (accessed on localhost:8000):
Start server and watch javascript/scss changes:
php artisan serve
npm run watch
Basic Tinker:
php artisan tinker
>>> $User = new App\Models\User;
>>> $myuser = $User->find(1);
Prepare for production:
npm run production
APP_DEBUG=false in .env
- Create the site
composer create-project laravel/laravel simple-crm
- Get in the project folder
cd simple-crm
- Add Sanctum
composer require laravel/sanctum
- Publish the Sanctum configuration and migration files
php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider"
-
Create database simple_crm in phpMyAdmin (I used XAMPP)
-
Run database migrations
php artisan migrate
- Manual creation of the first user in the DB
user: a
email: a
password: $2y$10$EOty9ldgWCHHgocqOJw.MujyEx88.CmOJKmx/BLhQCYKFxdzwBswm (a)
- Create user controller
php artisan make:controller UserController
- Test token creation http://localhost:8000/api/login with following JSON
{
"email": "a",
"password": "a"
}
- Add Laravel UI support
composer require laravel/ui
- Add Vue.js boilerplate
php artisan ui vue
- Compile Vue.js using a "javascript command line"
npm install
npm run dev
use npm run watch to keep updated your vue, css files
- Install Vue Router (using javascript)
npm install vue-router
- Install Vuex
npm install vuex
- Install vuex-persistedstate
npm install --save vuex-persistedstate
- Make user group model, controller, migration
php artisan make:model UserGroup -mcr
- Migration for new column 'user_group_id' in users
php artisan make:migration add_column_to_users
php artisan migrate
- DB Seeder
php artisan db:seed
- Install bootstrap-vue (js)
npm install bootstrap-vue
- Make Country model, controller, migration
php artisan make:model Country -mcr
php artisan migrate
php artisan make:seeder CountrySeeder
php artisan db:seed
- Migration to add column deleted_at in user_groups table (soft-deleting)
php artisan make:migration add_column_to_user_groups
php artisan migrate
- Migration to add column deleted_at in users table (soft-deleting)
php artisan make:migration add_column_soft-deleting_to_users
php artisan migrate
- Make Company model, controller, migration
php artisan make:model Company -mcr
php artisan migrate
php artisan make:seeder CompanySeeder
php artisan db:seed
php artisan make:migration create_companies_user_groups_table
- Install javascript moment package
npm install moment
- Make migration to add created_by to Company
php artisan make:migration add_column_created_by_to_companies
php artisan migrate
- Make Contact model, controller, migration
php artisan make:model Contact -mcr
php artisan migrate
php artisan make:seeder ContactSeeder
php artisan db:seed
- Make migration to create contacts_user_groups table
php artisan make:migration create_contacts_user_groups_table
php artisan migrate
- Make Product model, controller, migration
php artisan make:model Product -mcr
php artisan migrate
php artisan make:seeder ProductSeeder
php artisan db:seed
- Make migration to create products_user_groups table
php artisan make:migration create_products_user_groups_table
php artisan migrate
- Make Order/OrderProduct/License model, controller, migration
php artisan make:model Order -mcr
php artisan make:migration create_orders_user_groups_table
php artisan make:model OrderProduct -mcr (migration manually renamed to create_orders_products_table)
php artisan make:model License -mcr
php artisan migrate
php artisan make:seeder OrderSeeder
php artisan db:seed