LARAVEL

How to build a Project Management App in Laravel 5 – Part 2


Let’s continue from our previous post.

We refreshed the page and it gave us an error because we deleted the view responsible for showing us the Laravel 5 page.

1. Create Home Controller and Index Template

You can run the artisan command like so:

..and that will create a HomeController.php file with some boilerplate methods for a basic CRUD operation on a controller.

OR

You can just create the HomeController.php file manually.

I created the HomeController.php file using the artisan command and I have added a line of code to the index function to return a view. Delete the other methods:

Let’s go to our routes.php.

Eliminate the code there and add this:

Let’s go ahead and create our index.blade.php in the resources/views folder.

index.blade.php

Then create a layouts folder and inside the folder, create a master.blade.php file

master.blade.php

Create a css and images folder within the public directory and create an app.css file in the css folder. projectmanagement.gif is just an image I downloaded. You can use any image for this, just make sure it is within the images folder.

In the master.blade.php, add this:

Now, let’s refresh our page, it should look like this:

Aha!!..Nice. We are getting somewhere but wait we have only just begun! :smile:

Now commit to git if you haven’t done that.

2. Create the alerts partial template

Head over to the layouts folder and create a partials folder within it. Now, this is where all our different partial templates would reside.

So the first partial template we’ll create would be alerts.blade.php. Go ahead and create it.

alerts.blade.php

All our status messages and notifications would be rendered with this template.

So, go to your master.blade.php and include the alerts template. Now your master.blade.php would look like this:

4. Database Migrations

Now, it’s time for us to create our migrations for this project. These are the tables I have in mind.

Note: I haven’t pre-built this app, I am building as I am teaching, so some things might changes along the way but it’s

User table (users)

id

username

email

password

first_name

last_name

avatar_url

remember_token

timestamps – created_at, updated_at

Project table ( projects)

id

project_name

project_notes

project_status

user_id – ( Foreign Key )

due_date

timestamps – created_at, updated_at

Task table (tasks)

id

task_name

timestamps – created_at, updated_at

project_id

Todo table (todos)

id

todo_name

todo_description

todo_status

user_id ( Foreign Key )

due_date

timestamps – created_at, updated_at

Comment table (comments)

id

comments

project_id

user_id

timestamps – created_at, updated_at

File table ( files)

id

file_name

file_url

project_id

timestamps – created_at, updated_at

Project – Collaborators table ( project_collaborator )

id

project_id

collaborator_id

Let’s make our migrations now. Laravel has a command line tool where commands can be run to create migration files. Run all these commands from the terminal to create boilerplates for the different tables.

DATE_create_users_table.php

DATE_projects_table.php

DATE_create_tasks_table.php

DATE_todos_table.php

DATE_create_comments_table.php

DATE_create_files_table.php

DATE_create_projects_collaborators_table.php

Now, go ahead and run the migrations

 

Make sure you have the database set in your .env file . Every Laravel project must have a .env file your database and secret credentials. This is mine currently. Remember to gitignore this file. It must not be pushed to GitHub because you don’t want others seeing your secret credentials.

My username and password are homestead and secret respectively because I am using a homestead box

Check your database, All these tables would have been created now just by running  a command. Awesome!

It’s good that you have gotten to this stage, there’s still more to explore. Let’s keep moving!.

Watch out for the next post! :smile:

Please if you have any questions or observations, feel free to drop it the comments section below.

PROSPER OTEMUYIWA

About PROSPER OTEMUYIWA

Food Ninja, Code Slinger, Technical Trainer, Accidental Writer, Open Source Advocate and Developer Evangelist.