nathanrobjohn

nathanrobjohn

Member Since 4 Years Ago

Experience Points 5,485
Experience Level 2

4,515 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 61
Lessons
Completed
Best Reply Awards 2
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

30 Dec
3 years ago

nathanrobjohn left a reply on Search Not Working For All Fields

Use

$results = DB::table('users') ->select('first_name','last_name','profession','id') ->orWhere('country','LIKE','%$country%') ->orWhere('state','LIKE','%$state%') ->orWhere('city','LIKE','%$city%') ->orWhere('zip','LIKE','%$zip%') ->get();

            return view('backend.searchjobseeker.view'
                               ,compact('results'));
23 Dec
3 years ago

nathanrobjohn started a new conversation Routes Not Working

Hi Guys,

For some reason i have moved my site over to a new computer and now my routes aren't working. they show in the route list and i can get the home page but no other pages.

Any help would really be appreciated

Regards

27 Aug
3 years ago

nathanrobjohn left a reply on Socialite Implemented, And Now? Next Steps?

You would save the user to the database with the provider and the provider id and then everytime someone trys to login with social accounts check if they exists in the database and if they do then login otherwise create user and login

25 Aug
3 years ago

nathanrobjohn left a reply on Where Are You All From?

Cardiff, Wales, UK

24 Aug
3 years ago

nathanrobjohn left a reply on [HELP] Does Post Belong Do Auth::user Middleware

You are probably better doing this inside your method. something like this

``

public function show($id)
{
    $funnyEvent = FunnyEvent::find($id);
    if(Auth::id() != $funnyEvent->createdBy) {
        Flash::error('This is not your funny event.');
        return Redirect::route('/');
    }
}

``

21 Aug
3 years ago

nathanrobjohn left a reply on If Statement On Search Result

you have no input field in your form?

25 Jul
3 years ago

nathanrobjohn left a reply on Larval & JQuery

They were added dynamically with vue.js not jquery search the site for vue.js

nathanrobjohn left a reply on Site Notifications

Works perfectly fine for me

24 Jul
3 years ago

nathanrobjohn left a reply on If(Auth::attempt($data)) Fails Every Time My Username And Password Is Right Then Also

And i am sure the auth::attempt takes the non hashed version of the password and then bcrypts it and checks it against the database. is there a reason why you are using sha512?

19 Jul
3 years ago

nathanrobjohn left a reply on Eloquent Not Saving For Some Strange Reason!

@bdschr what error are you getting and what is the primary key in your table?

nathanrobjohn left a reply on Eloquent Not Saving For Some Strange Reason!

try

public function admin_serverposts()
    {
        $input = Input::all();
        $request_page = Session::get('request_page');
        $vpnservers = new Vpnservers;

        if ($request_page == 'server_add') {
            $validator = Validator::make($input, [
                'ip_address' => 'required',
                'country' => 'required',
                'cert' => 'required'
                ]);
        
                if (!$validator->fails()) {
           $vpmservers = new VpnServers;
                    $vpnservers->ip_address = $input['ip_address'];
                    $vpnservers->country = $input['country'];
                    $vpnservers->cert = $input['cert'];
                    $vpnservers->save();
        
                    return redirect()->route('admin.servers');
                }
        
                return redirect()->back()->withErrors($validator);
        
            }
        }

nathanrobjohn left a reply on Can't Retrieve User In Middleware

Hi Chris,

Thank you for helping and going through it last night, i think it was a lack of sleep. I just took over this project and the previous developer wasn't using any of Laravel's built in functionality he was creating user sessions manually. When i was trying to use Laravel Auth functionality to login the user it was checking table Person for fields "Email", "password" where in my table the password field is named "Password" so it was always returning false. I fixed the issue by changing the field that Laravel checks again here is what i done to fix the issue

public function getAuthPassword() {
        return $this->Password;
}

inside of my user model.

Thanks for helping

18 Jul
3 years ago

nathanrobjohn started a new conversation Can't Retrieve User In Middleware

Hi Guys,

I am trying to use a middleware to check if user is logged in and if they are admin.

here is my code http://pastebin.com/89kg0iuR

If i remove the middleware everything works fine and i get logged in and redirected correctly. if i try and use the middleware and try and dd the user i always get null no matter what i try does anyone know why?

nathanrobjohn left a reply on Usign Eloquent - 's' Is Added To Database Table Names

Ignore me sorry

protected $table = "userinfo";

nathanrobjohn left a reply on Usign Eloquent - 's' Is Added To Database Table Names

In your eloquent model have you set the table name?

In your model try

''' Private $tablename = "userinfo";

'''

15 Jul
3 years ago

nathanrobjohn left a reply on Where To Place Session Logic

So the site basically its a travel tour website so user goes to site searches a location and picks a bus time and its then carried through sessions until they checkout so every page has


                Session::put('PersonName', $user->FirstName . ' ' . $user->MiddleName . ' ' . $user->LastName);
                Session::put('PersonID', $user->PersonID);
                Session::put('Email', $user->Email);
                Session::put('MobilePhone', $user->MobilePhone);

nathanrobjohn started a new conversation Where To Place Session Logic

Hi Guys,

I am just wondering where you put all session logic? an app i have taken over its currently all in controllers so your constantly repeating yourself and i am trying to stick to DRY theory where would you suggest putting the logic?

12 Jul
3 years ago

nathanrobjohn started a new conversation Error On Settings -> Viewing History Page

Hi @JeffreyWay

Just to let you know when your are viewing your viewing history and try to go to page 2 etc it changes the get in the url but the results do not change.

nathanrobjohn left a reply on Php Artisan / Call To Undefind Method

@StuffedGoat Found the problem!

I was using dev-master version of the kodeine acl package which now only supports laravel 5.1 due to some blade functions being deprecated. changed kodeine to use v1 and now all working again.

11 Jul
3 years ago

nathanrobjohn left a reply on Php Artisan / Call To Undefind Method

No one else was working on the project and thats all the information it gives me also the project was working earlier and all i did was composer update and this issue arised. I seen people saying about a compile.php file but i can't see one in any of my folders not sure whats going on and really bugging me now

nathanrobjohn started a new conversation Php Artisan / Call To Undefind Method

Hi Guys,

I have gone back to a project i was working on 2/3 months ago and when i run php artisan clear-compiled of php artisan optimize i get the following error

call to undefined method Illuminate\view\compilers\bladecompiler::directive

Has anyone else had this problem?

09 Jul
3 years ago

nathanrobjohn left a reply on Help With Laravel Redirect::back()

@bashy most of the code above is not mine and i am currently just extracting everything from the controllers into their rightful place but will be going through everything. but thanks for tip bash

nathanrobjohn left a reply on Help With Laravel Redirect::back()

omg donut sorry have been up all night trying to clear everything up! thank you guys! my fault.

nathanrobjohn started a new conversation Help With Laravel Redirect::back()

Hi Guys,

I picked up a project that needed a huge refactor as everything is currently inside the controllers and models.

I moved the checkout login process with the db to a repo here is my controller

<?php

namespace App\Http\Controllers;

use DB;
use App\Http\Controllers\Controller;
use App\User;
use App\Wishlist;
use App\Order;
use App\Place;
use App\Common;
use App\Http\Requests;
use App\Http\Requests\CheckoutLoginRequest;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Http\RedirectResponse;
use Validator;
use Input;
use Auth;
use Illuminate\Support\Facades\Hash;
use Session;
use Gloudemans\Shoppingcart\Facades\Cart;
use App\Repositories\UserRepositoryInterface;
use Mail;

class UsersController extends Controller
{

    public function __construct(UserRepositoryInterface $users)
    {
        $this->users = $users;
        session_start();
    }
   

    /**
     * Login via checkout with basket
     * @param CheckoutLoginRequest $request
     */
    public function checkoutLogin(CheckoutLoginRequest $request)
    {
        $this->users->checkoutLogin($request);
    }


}

and here is my user repo

<?php

namespace App\Repositories\Eloquent;

use App\User;
use App\Http\Requests;
use Auth;
use App\Repositories\UserRepositoryInterface;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Hash;
use Session;
use Gloudemans\Shoppingcart\Facades\Cart;

class UserRepository implements UserRepositoryInterface {

    /**
     * Create a new UserRepository instance.
     *
     * @param  \App\User  $user
     * @return void
     */
    public function __construct(User $user)
    {
        $this->user = $user;
    }

    /**
     * Get current user.
     *
     */
    public function currentUser()
    {
        $currentUser = Auth::user();
        return $currentUser;
    }

    /**
     * Find all users
     * @return $users
     */
    public function findAll()
    {
        return $this->user->orderBy('created_at', 'desc');
    }


    /**
     * Find all users paginated.
     *
     * @param int $perPage
     * @return $users
     */
    public function findAllPaginated($perPage = 10)
    {
        return $this->user->orderBy('created_at', 'desc')->paginate($perPage);
    }

    /**
     * Register user
     *
     * @param $request
     */
    public function register($request)
    {

    }

    /**
     * Login via checkout with basket
     * @param $request
     * @return View
     */
    public function checkoutLogin($request)
    {

        if (empty($_SESSION['captcha']) || trim(strtolower($_REQUEST['captcha'])) != $_SESSION['captcha']) {

            Session::flash('login', 'function');
            return Redirect::back()->withErrors("Invalid captcha");

        } else {

            $user = $this->user->where('email', '=', $request['email'])->first();

            if( Hash::check($request['password'], $user->Password) ){
                    Auth::login($user);
                    $user = Auth::user();
                    Session::put('PersonName', $user->FirstName.' '.$user->MiddleName.' '.$user->LastName);
                    Session::put('PersonID', $user->PersonID);
                    Session::put('Email', $user->Email);
                    Session::put('MobilePhone', $user->MobilePhone);

                    $carts = Cart::content();

                    foreach($carts as $cart)
                    {
                    }
                    if(!empty($cart))
                    {
                        //Todo Fix this (not redirecting back properly)
                        return Redirect::back();
                    }
                    else
                    {
                        return redirect('/');
                    }
            } else {

                Session::flash('login', 'function');
                return Redirect::back()->withErrors(array('loginerror' => 'The account entered has not been found.'));

            }
        }

    }

    /**
     * Get User by id
     * @param $id
     * @return $user
     */
    public function getUserById($id) {
        return $this->user->where('PersonID','=',$id)->first();
    }


    /**
     * Delete User by id
     * @param $id
     * @return redirect
     */
    public function deleteUserById($id) {
        return $this->user->where('PersonID','=',$id)->delete();
    }

    /**
     * Get User by Email
     * @param $email
     * @return $user
     */
    public function getUserByEmail($email) {
        return $this->user->where('Email','=',$email)->first();
    }

    /**
     * Logout user
     */
    public function logoutUser() {
        Auth::logout();
        Session::flush();
    }

} 

Inside the function checkoutLogin once they have logged in and if something is in the cart i am trying to redirect back but for some reason i just get a blank white page if i dump and die Redirect::back() i get

RedirectResponse {#288 ▼
  #request: Request {#37 ▼
    #json: null
    #sessionStore: null
    #userResolver: Closure {#227 ▶}
    #routeResolver: Closure {#245 ▶}
    +attributes: ParameterBag {#39 ▶}
    +request: ParameterBag {#38 ▶}
    +query: ParameterBag {#45 ▶}
    +server: ServerBag {#42 ▶}
    +files: FileBag {#41 ▶}
    +cookies: ParameterBag {#40 ▶}
    +headers: HeaderBag {#43 ▶}
    #content: "_token=QdcPNtsmCk5kmXisA4nYYrN8EffY7t97qdH6yk4n&email=nathanrobjohn%40gmail.com&password=&captcha=venomed"
    #languages: null
    #charsets: null
    #encodings: null
    #acceptableContentTypes: null
    #pathInfo: "/checkoutlogin"
    #requestUri: "/aerobus/public/checkoutlogin"
    #baseUrl: "/aerobus/public"
    #basePath: null
    #method: "POST"
    #format: null
    #session: Store {#205 ▶}
    #locale: null
    #defaultLocale: "en"
  }
  #session: Store {#205 ▶}
  #targetUrl: "http://localhost:812/aerobus/public/makepayment"
  +headers: ResponseHeaderBag {#287 ▶}
  #content: """
    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8" />
            <meta http-equiv="refresh" content="1;url=http://localhost:812/aerobus/public/makepayment" />
    
            <title>Redirecting to http://localhost:812/aerobus/public/makepayment</title>
        </head>
        <body>
            Redirecting to <a href="http://localhost:812/aerobus/public/makepayment">http://localhost:812/aerobus/public/makepayment</a>.
        </body>
    </html>"""
  #version: "1.0"
  #statusCode: 302
  #statusText: "Found"
  #charset: null
}
28 Jun
3 years ago

nathanrobjohn left a reply on Who Is Still Supporting IE 6 Or 7 Or 8?

@jlrdw Doesn't seem to work on my Sony Xperia Z2 or my Iphone 6 plus http://postimg.org/image/5dfpe76tr/

27 Jun
3 years ago

nathanrobjohn left a reply on Who Is Still Supporting IE 6 Or 7 Or 8?

@jlrdw I think you are in past times and need to catch up. I have always supported IE8 and up. Even sites on Google now are better indexed if they are responsive. Just because a website does not support IE6 or IE7 doesn't mean the website has been developed badly? or am I on another planet. I think the points you have made are invalid and in every industry if people don't move with the times then that industry gets left behind. Take PHP for example PHP was old and outdated to other languages and in recent years PHP has advanced and now is thought after alot more. I mean the site you linked to http://taylorjoneshumane.com/index.html yes it works in all IE versions but its unfriendly to the user, its dated and is actually hard to navigate so i don't see how the website you linked to has more advantages than disadvantages. I think the older generation would find that site harder to navigate than a more modern website. The fact that mobile website viewing is on bar or over the percentage of desktop viewing shows that IE6/IE7 and maybe IE8 need to be left alone. IE8 is not even supported by windows anymore. I even see people in their 70's and over using an iphone etc so there is no excuse for supporting something that even the manufacturer doesn't even support anymore. There is a time to let go of everything.

26 Jun
3 years ago

nathanrobjohn left a reply on Laravel 5, Commands And Domain Events.

@Corbin

A job would be maybe queuing 500 photos and then in that job once the job has finished you would maybe fire an event to the user e.g event::(user.photos.upload) if you understand what i mean

nathanrobjohn left a reply on Laravel 5, Commands And Domain Events.

Hi @Corbin That is correct i am also learning and that is what i understand that these are for the hardest part i find about learning is the amount of different words people use for the same thing. So many times i have looked up something that someone has mentioned as i haven't heard it before but it is something i already know under another name.

22 Jun
3 years ago

nathanrobjohn left a reply on Text Message API

Do you know their rates?

21 Jun
3 years ago

nathanrobjohn left a reply on Once Again Data Not Being Inserted

i would change the checkbox column in the table to be a boolean

$table->boolean('haveFirstAid')->default(false);

then inside your form i would have

<span class="labels">First Aid?</span>
{!! Form::checkbox('haveFirstAid', '0') !!}

then inside your store function

public function store($request)
    {
        $modelname->haveFirstAid= $request->has('haveFirstAid');
    }

nathanrobjohn left a reply on Once Again Data Not Being Inserted

For a checkbox you would only have one as yes would be ticked and no would be unticked and can you post controller how are you getting the result from checkbox?

20 Jun
3 years ago

nathanrobjohn left a reply on Hidden Variable Form To Controller Method.

If you are on an event page e.g www.someurl.com/event/123

Then in your store controller pass through the $id e.g

Public function store(commentrequest $request, $id) { $event_id = event::findbyId($id) }

14 Jun
3 years ago

nathanrobjohn left a reply on Upload Files Using DropzoneJS With Other Fields

@4goodapp sorry i just realised was tired eyes when i looked will take a look now can you show your full controller

13 Jun
3 years ago

nathanrobjohn left a reply on Upload Files Using DropzoneJS With Other Fields

Or add this to the use block at the top of your controller

use Request;

10 Jun
3 years ago

nathanrobjohn left a reply on BelongsTo And HasOne

So say you have a user model and a profile model each user would have one profile so user has one profile and then your profile model would belongTo one user

nathanrobjohn started a new conversation Where To Create Notifications?

Hi Guys,

I currently have an app where i have a notifications model and users model with a notifications repo and users repo, when a user registers in my user repo i create a notification. The question i have is 'is this the right place to put it', after watching the new 5.1 videos i got a gut feeling that i should been triggering events and then creating the notification inside of the listener? would this be right? and can anyone give me an example on how they would do it?

Regards Nathan

25 May
3 years ago

nathanrobjohn left a reply on Markdown Not Being Parsed As Expected

Can you supply more of your code? as can't really see whats going on with what you have supplied

23 May
3 years ago

nathanrobjohn left a reply on Any Way To Avoid Entering Controller Class Name In A Route::group()?

You could always user Route::resource() and just place the extra routes you need under neath Route::resource('photo', 'PhotoController'); Route::get('ConfirmDestory', 'PhotoController@ConfirmDestory');

17 May
3 years ago

nathanrobjohn left a reply on Edit Post By User And Admin Approval

@mstnorris thank you for the help so far i don't think that would work only using one table as you would then be creating a new post with a new id everytime that you accept a revision which then would obviously change id and won't index in google properly. kind of stumped with this i might go with what @Kryptonit3 suggested and change a few things and have two tables seems the most sensible for what i am looking for.

nathanrobjohn left a reply on Edit Post By User And Admin Approval

@mstnorris they are the same basically would you suggest something like this then? inside my blog posts model:

class BlogPosts extends Eloquent {

    public function __construct($posts , array $attributes = array())
    {
        parent::__construct($attributes);

        $this->table = $posts;
    }

}

then when creating post have :

$post = new BlogPosts('posts');

and when creating revision have :

$revisions = new BlogPosts('revisions');

nathanrobjohn left a reply on Edit Post By User And Admin Approval

@Kryptonit3 its not like a forum this is what i have currently

blog post model admin can edit , create blog post user can create blog post which then a admin must approve a user can edit a blog post

the last part i want the user to edit the blog post which they then submit and will be entered into a revisions table with the blog post id they have edited an admin would then review the edit and once the admin clicks accept edit it would then find the live blog post from the post_id column in the revisions table and copy the content from the row in the revisions table to the current blog post

i might be saying it wrong but wouldn't it be easier to have the following:

Blog post model : has many revisions

| ID | title | content | |---- |------- |--------- | | 1 | John | doe |

Revisions model : belongs to post

| ID | title | content | post_id | |---- |------- |--------- |--------- | | 1 | John | doe | 1 |

@mstnorris

nathanrobjohn left a reply on Edit Post By User And Admin Approval

@mstnorris i get what your saying but obviously there will be a post and won;t be any revisions until a frontend user edit's a post as a admin would always update the active posts. How else would you go about it if not creating a model for revisions? i am going to go with the way @Kryptonit3 explained but i would of created a Revisions model and table and have the table like explained above? then when a front end user edits a post then it will go into the revisions table for an admin to approve and once approved will find the current post id inside of the revisions column and then post the new content to the current post? in my head the current post would never change id etc it would just update the content from the revision

nathanrobjohn left a reply on Edit Post By User And Admin Approval

@Kryptonit3 Would you recommend maybe having a revisions model with a revisions table?

thank you for all the help and replies

nathanrobjohn left a reply on Edit Post By User And Admin Approval

Thank you @mstnorris that is currently how i have it set up but obviously the post will disappear on the front end , this is probably my fault as i didn't explain properly i want to be able to keep the post live and make a duplicate of the "live" post and then copy the edits across if the admin approves the changes.

@Kryptonit3 Thank you for your answer this is how i want it so work but would i be able to have multiple edits? from different users?

nathanrobjohn started a new conversation Edit Post By User And Admin Approval

Hi Guys,

I am trying to think of a way that a user can edit a post on the frontend but a admin has to approve before the update is made? i can't seem to figure out the best solution for this, does anyone have any suggestions on how to make this work?

Regards Nathan

16 May
3 years ago

nathanrobjohn left a reply on Database Relationship Help

Need to add workout has many exercise

12 May
3 years ago

nathanrobjohn left a reply on Looking For Some DDD Contributors

Hi there,

One thing i noticed straight away is your name spaces need blank line above and below and same on your use statement block if you want to follow psr 2

09 May
3 years ago

nathanrobjohn left a reply on Client/ Admin Authorization System

I recommend using the kodeine-acl package excellent package and easy to set up

05 May
3 years ago

nathanrobjohn left a reply on Login ACL - Multiple Types Of User Logins

I would recommend using the kodeine-acl package its easy to set up and works really well