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

We need to make a little adjustment.

On the Sign In page, you will discover that if the email or password is wrong, it doesn’t show the user a message, it just blocks the user from gaining access. Let’s take care of that.

Add this in:


Go to AuthController.php

I have changed info to warning in that block of code.

One more thing. Go to login.blade.php

Add @include('layouts.partials.alerts')  in between the h3 tag and the div.

Now, if a user wants to login and the credentials are wrong, the user will see an appropriate error message.

Go to AuthController.php

In the postLogin function we had

Change it to

We want the users to be redirected to see all their projects once they are logged in.

Go to views/index.blade.php

We had something like this:

We are going to replace part of that code with the sidebar blade template. We don’t want repetition.

We have removed the sidebar div and replaced it with @include('layouts.partials.sidebar') .

If you don’t have the sidebar template, create a sidebar.blade.php file in layouts/partials folder and dump the contents in it:


Now, if a new user creates an account and logs in, the user can see the projects of other users. That doesn’t make sense. We need to make the user have access to only his/her own projects.

Let’s get to work

We’ll use the concepts of Scopes in Laravel. Query scopes are convenient ways to isolate often used conditions when querying your database for information.

Go to the Project model


Add this function to the class:

Make sure you require Auth at the top like so:

just before use IlluminateDatabaseEloquentModel;

Now, go to ProjectController.php

will become

We just called the personal() from the QueryScope method we wrote in the Project Model. Awesome!!!

If you reload your projects page. You will discover that a user can only see his/her own projects.

Time to view each Project

Create a show.blade.php in projects folder


Go to ProjectController.php

We already have a show function created by Laravel when we used the command to create the controller earlier.

Let’s add to the function

Project::find($id); basically  does a select * from projects where id = $id and then return the results to the show view.

Go to projects/index.blade.php

Before we didn’t have a link there, but now we want the name of the project to be clickable. $proj->id gets the id. So, if the id of that particular project is 5, then we’ll have a link like projects/5 .

When a user clicks on that link, the id is passed to the show method in the Project Controller that then renders the features of that project in the view.

I have also added the tasks, files and comments form.

Now we can’t edit or delete the project yet, but we’ll take care of that functionality in the next project.

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




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