Alief’s Update — Week 13

Alief Aziz
Inspire Crawler
Published in
4 min readMay 22, 2016

In this week I tried to achieved what I could never achieve in the previous week, that is spent more than 10 hours. The result ? I just got 6 hours and 17 minutes :( , hmm perhaps I should try harder next time (on the last week in PPL) . Anyway, here are what I’ve done :

  1. Clean up my git Folder (Version Control)

a. Git Setup :

git clone <link>

b. Merge conflict :

If we work on different branch, lets say build two different feature, sometimes we must merge our work with the other. This will make a merge conflict error, we cannot commit our work if we still have merge conflict error. To see what kind of conflict we get, just enter “git status”, here are some example :

merge conflict

There are some type of merge conflict, they are :

> Added by them/us = It means, ‘their/ours’ branch have new files, and we are ask wether to accept it or not.
to solve it, we need to add the file by executing

git add <filename>

> Both Modified = It means, ‘their’ and ‘ours’ have same file but different content, and we are asked to choose/merge the conflicted lines.

The marks ‘<<<<<<HEAD’ until ‘=====’ contain code from ‘ours’ while ‘=====’ until ‘>>>>> <branch-name>’ contain code from ‘theirs’. To merge file quickly we can use these commands

# Quickly accept all changes from local
git checkout --ours -- <filename>
# Quickly accept all changes from remote
git checkout --theirs -- <filename>

To solve it we have to choose / merge those code then add the file by using

git add <filename>

> Deleted by them/us = It means, ‘their/ours’ branch have deleted the file, and we are ask wether to accept it or not.
to solve it, we need to add the file by executing

git rm <filename>

c. Tracking

untrack files : git will not look upon the files
how : add the filename to “.gitignore”

2. Completing Task (done)

Code Update function

update form
success on updating

To make this function work, firstly I edit the CRUDController to handle update request. I edit method edit($id), to redirect to update page. Then I create update page, this is the page where the form to update the quotes are shown. The submit button of this page will redirect to method update(Request,id) in CRUDController. This method then will communicate to the database(mlab) using defined function from Jenssegers library.

In the process on making this function, I encountered a problem. This problem I faced when I try to route the submit button to update method in “CRUDController”. Because we use Resource Controller so we can’t use direct link, we have to know the “alias” for the real link. The link that I want to target is “admin/CRUD”, but when I enter it, laravel doesn’t acknowledge the link I enter. After asking some help from my friend, I have to add parameter ‘names’ in route to “admin.update”. Finally laravel could redirect to expected page.

I follow tutorial from this site.
source : route, view, controller

3. Get information about Login / Logout in Laravel (Role Management)

Here are some information that I gathered from google.
The main steps that are required to make role management in laravel are :
a. Creating a users table using migrations
migration is some kind of “lazy” way to modify the database in laravel, but since we’re using MongoDB we cannot use migration build-in function. Luckily there is library called Jenssegers to achive the same result as migration
b. Filling our new users table with sample users using seeding
Seeding is a method to automate fill the database with dummy data, seed function also already built in the laravel. But once again, we are using MongoDB so everything will be different. To mimic this function, I have to make my own function to fill the database with dummy data. This dummy useful for testing, especially security testing.
c. Creating a login form and processing a login using routes, controllers, and views
d. Handling login errors

source

--

--