I have simply followed Laravel documentation for setting up Vue.js
Here is the link – https://laravel.com/docs/5.4/frontend#writing-javascript
When the build is ready, add app.js from the public folder to your blade.php page’s footer
Issues:
If you are getting an error saying the components not found, it means your script is executing before the document is ready
Make sure you have added app.js script at the end of the page
Adding new component (similar to ‘example’ component given with Laravel):
Components:
Components are one of the most powerful features of Vue. They help you extend basic HTML elements to encapsulate reusable code. At a high level, components are custom elements that Vue’s compiler attaches behavior to. In some cases, they may also appear as a native HTML element extended with the special is attribute.
Create a new component in resources/components called Greeting.vue
Add your bootstrap element inside template element
Create an instance of ‘greeting’ component in app.js
Add <greeting></greeting> element to your blade.php page
You should be able to see the Greeting.vue template appear on the page
camelCase vs. kebab-case
HTML attributes are case-insensitive, so when using non-string templates, camelCased prop names need to use their kebab-case (hyphen-delimited) equivalents:
Vue.component(‘child’, {
// camelCase in JavaScript
props: [‘myMessage’],
template: ‘<span>{{ myMessage }}</span>’
})
<!– kebab-case in HTML –>
<childmy-message=“hello!”></child>
Again, if you’re using string templates, then this limitation does not apply.
Adding a Vue message to the page: (Declarative rendering)
Middleware provides convenient mechanism for HTTP requests entering your application. For example, Laravel includes a middleware that verifies the user of your application is authenticated. If the user is not authenticated, the middleware will redirect the user to the login screen. However, if the user is authenticated, the middleware will allow the request to proceed further into the application.
Specify the database being used in config/database.php
If you’re using sqlite, create an “database.sqlite” file in either databses or storage. We do not need to edit the “.env” file
Setting the path for database.sqlite
folder names are referenced with “_path” Eg: storage folder as “storage_path()”, database folder as “database_path()”
If the file is in the storage folder then you can write “storage_path(‘database.sqlite’)”, else if it is in the database folder then you can write “database_path(‘database.sqlite’)”
If you’re using mysql change the authentication details and edit the “.env” file
Migrations:
First we will need to set up database schema.
Migrations are version control for databases
Usually you create tables using GUI but these migrations help you create tables in the app. It will help the team to work with tables without using GUI but with code
Creating a migration doesn’t create the table. It will need to be migrated to get the tables created
You want to make a migration: Check these commands
php artisan make:migration nameofmigration
php artisan migrate — This will create the tables in the database
You can roll back using Down functions in the migration class
Laravel includes a simple method of seeding your database with test data using seed classes. All seed classes are stored in database/seeds. Seed classes may have any name you wish, but probably should follow some sensible convention, such as UsersTableSeeder, etc.
Adding some data to the tables for viewing something on the browser
Use “php artisan make:seeder UsersTableSeeder”
Add insert statements in the run method
DB::table(‘words’)->insert([ ‘word’=>’Modest’, ‘meaning’=>’Refusing to take any credit’, ‘language’=>’English’ ]);
Fixing mass assignment exception by addin – protected $guarded = []; to model “user.php” in app folder
You can start adding users
Note – If the primary key is not ‘id’ for a table it won’t update. You’ll have to change the the primary key in your model (Eloquent ORM (Object Reference Model)). Eg -> protected $primarykey=’userid’;
CRUD operations done
Flash Messages:
These are the messages that can be shown after a successful request
Things to do:
How to remove /public/app etc and make it /app without giving access to .env file?
How to add bootstrap & styling?
How to add JS if required?
How to move this localhost built app to a new server?
Using Laravel:
1) Created database for Laravel, you can see the options in for various database servers on config.php
2) Use any database server and set the parameters on config/database.php and also on the ‘env’ file on the root directory
3) for installing migration “php artisan migrate:install”
4) migrate table gets created
5) to make a migration “php artisan make:migration create_authors_table”
6) on successful creation open migrations, open the created migration
7) create schema in ‘up’ function of the class, drop schema in ‘down’ function
8) Schema query builder is used for creating tables
9) run migrations by using “php artisan migrate”
10) fluent query builder is used for inserting & updating tables
11) DB:: for crud operation into table
12) php artisan migrate:rollback for executing ‘down’ in the migrations (1 step at a time)
13) php artisan migrate:reset for executing ‘down’ on all migrations at once