nanpaul68

Software Developer at nHub Nigeria

Experience

4,600

2 Best Reply Awards

  • Member Since 11 Months Ago
  • 12 Lessons Completed
  • 0 Favorites

17th July, 2017

nanpaul68 left a reply on Send Email In Laravel • 1 week ago

Post your code so we can see what you have done, then we'll know how to help you.

nanpaul68 left a reply on Contact Form Error View [contact.contact] Not Found • 1 week ago

Why not use [laravelcollective](https://laravelcollective.com/docs/5.1/html).

or better still you can just add it to the require section of your composer.json file e.g

"require": {
    "laravelcollective/html": "5.1.*"
}

Next, update Composer from the Terminal:

composer update

Next, add your new provider to the providers array of config/app.php:

'providers' => [
    // ...
    Collective\Html\HtmlServiceProvider::class,
    // ...
  ],

Finally, add two class aliases to the aliases array of config/app.php:

'aliases' => [
    // ...
      'Form' => Collective\Html\FormFacade::class,
      'Html' => Collective\Html\HtmlFacade::class,
    // ...
  ],

on your view file:

{{ Form::open(['url' => 'foo/bar']) }}

11th July, 2017

nanpaul68 left a reply on Check For Existence Of A File • 2 weeks ago

You might want to try this. Though in my own case, i'm using Cartalyst Sentinel to handle authentication and access role.

@if(!Sentinel::getUser()->profile_pic)
    <img src="/public/uploads/default.png" alt="user pic">
@else
    <img src="{{ Sentinel::getUser()->profile_pic }}" alt="user pic">
@endif 

Hope this solve your problem...

11th June, 2017

nanpaul68 left a reply on Filter By Other Table • 1 month ago

You have to show what you've done already that is not working

nanpaul68 left a reply on Laravel • 1 month ago

@mianshargeel You are being denied access because its possible that your DB is not set to use a password to login, if it is set to use a password then you need to check to see if the password you are using is correct.

10th June, 2017

nanpaul68 left a reply on Laravel • 1 month ago

After creating the database and setting up the DB parameters in your .env file, make sure you run the artisan command

php artisan migrate

to migrate your tables.

9th June, 2017

nanpaul68 left a reply on Laravel Email Not Send On Share Hosting • 1 month ago

It could be a security issue from google allowing your app to send emails on your behalf. I had that issue once and had to use sendgrid

nanpaul68 left a reply on Nothing To Show • 1 month ago

You have to show us your approach that is not working, then we can help you.

nanpaul68 left a reply on Cant Create User • 1 month ago

use App\User;

public function create(Request $request) {
    $user = new \User;
    $user->name = $request->name;
    $user->email = $request->email;
    ........
    $user->save();
    return redirect()->route('your_uri');
}

2nd June, 2017

nanpaul68 left a reply on How To Create URL Slugs In Laravel • 1 month ago

Check my solution above. The slug is generated from my title field coming from the request. Why not have the slug column on the products table.

nanpaul68 left a reply on How To Create URL Slugs In Laravel • 1 month ago

This work for me and you can try it out:

// Store Method
public function store(Request $request) {
    $game->title = $request->title;
    $str = strtolower($request->title);
    $game->slug = preg_replace('/\s+/', '-', $str);
}
// Show Method
public function show($slug){
    $game = Game::where('slug', $slug)->first();
    return view('game.show')->with('game', $game);
}
// Route
Route::get('/detailPage/{slug}', [email protected]')->name('show_game');

6th May, 2017

nanpaul68 left a reply on Laravel 5.4 TokenMismatchException In VerifyCsrfToken.php Line 68 On Some Device • 2 months ago

use {{ csrf_field() }} in your form or better still you should use Laravel collective

26th January, 2017

nanpaul68 left a reply on Laravel 5.4 Failing On Php Artisan Migrate After Php Artisan Make:auth • 6 months ago

to fix this, all you have to do is to edit your AppServiceProvider.php file and add to the boot method a default string length

use Illuminate\Support\Facades\Schema;

function boot()
{
    Schema::defaultStringLength(191);
}

4th January, 2017

nanpaul68 left a reply on Error Using Twitter Auth • 6 months ago

Hi, I've figured out what the problem was. From L5 and up, the Input class has been replaced with Request. So i updated my Controller to look like:

//Read logged in user Twitter feeds
    public function twitterFeed() {
        if (Auth::check()) {
                $tweets = Twitter::getHomeTimeline(
                array(
                'screen_name' => Auth::user()->twitter_id, 
                'count' => 5, 
                'format' => 'object'
            ));
            
            // your SIGN IN WITH TWITTER  button should point to this route
            $sign_in_twitter = true;
            $force_login = false;
        
            // Make sure we make this request w/o tokens, overwrite the default values in case of login.
            Twitter::reconfig(['token' => '', 'secret' => '']);
            $token = Twitter::getRequestToken(route('twitter_callback'));
        
            if (isset($token['oauth_token_secret']))
            {
                $url = Twitter::getAuthorizeURL($token, $sign_in_twitter, $force_login);
        
                Session::put('oauth_state', 'start');
                Session::put('oauth_request_token', $token['oauth_token']);
                Session::put('oauth_request_token_secret', $token['oauth_token_secret']);
        
                return Redirect::route('twitter_page');
            }
            return Redirect::route('twitter.error');
            
        } else {
            return redirect()->route('login');
        }
        return view('social_media.twitter', ['tweets' => $tweets]);
    }
    
    public function twitterCallback (Request $request) {
        
        // You should set this route on your Twitter Application settings as the callback
        // https://apps.twitter.com/app/YOUR-APP-ID/settings
        if (Session::has('oauth_request_token'))
        {
            $request_token = [
                'token'  => Session::get('oauth_request_token'),
                'secret' => Session::get('oauth_request_token_secret'),
            ];
    
            Twitter::reconfig($request_token);
    
            $oauth_verifier = false;
    
            if ($request->has('oauth_verifier'))
            {
                $oauth_verifier = $request->get('oauth_verifier');
            }
    
            // getAccessToken() will reset the token for you
            $token = Twitter::getAccessToken($oauth_verifier);
    
            if (!isset($token['oauth_token_secret']))
            {
                return Redirect::route('twitter.login')->with('flash_error', 'We could not log you in on Twitter.');
            }
    
            $credentials = Twitter::getCredentials();
    
            if (is_object($credentials) && !isset($credentials->error))
            {
                // $credentials contains the Twitter user object with all the info about the user.
                // Add here your own user logic, store profiles, create new users on your tables...you name it!
                // Typically you'll want to store at least, user id, name and access tokens
                // if you want to be able to call the API on behalf of your users.
    
                // This is also the moment to log in your users if you're using Laravel's Auth class
                // Auth::login($user) should do the trick.
    
                Session::put('access_token', $token);
    
                return Redirect::route('twitter_page')->with('flash_notice', 'Congrats! You\'ve successfully signed in!');
            }
    
            return Redirect::route('twitter.error')->with('flash_error', 'Crab! Something went wrong while signing you up!');
        }
    }

21st December, 2016

nanpaul68 started a new conversation Error Using Twitter Auth • 7 months ago

Hey,

i want to be able to make a tweet to user's twitter page and also read the user feeds from my laravel 5.3 app. But first of all, i need to authenticate the user in order to have access to the user's twitter page to make the post.

i'm using "thujohn/twitter": "^2.2" package.

I have done the setting up of the package base on this [GitHub Documentation] (https://github.com/thujohn/twitter).

This is how my controller look like:

Reading the feed

 public function twitterFeed() {
        
        $sign_in_twitter = true;
        $force_login = false;
    
        Twitter::reconfig(['token' => '', 'secret' => '']);
        $token = Twitter::getRequestToken(route('twitter_callback'));
    
        if (isset($token['oauth_token_secret'])) {
            
            $url = Twitter::getAuthorizeURL($token, $sign_in_twitter, $force_login);
            
            Session::put('oauth_state', 'start');
            Session::put('oauth_request_token', $token['oauth_token']);
            Session::put('oauth_request_token_secret', $token['oauth_token_secret']);
            
            return Redirect::to($url);
        }
        
        if (Auth::check()) {
            
                $tweets = Twitter::getUserTimeline(
                array(
                'screen_name' => Auth::user()->twitter_id, 
                'count' => 5, 
                'format' => 'object'
            ));
        } else {            
            return redirect()->route('login');
        }        
        return view('social_media.twitter', ['tweets' => $tweets]);
    }

// Callback url for successful auth twitter user

public function twitterCallback() {
        
        if (Session::has('oauth_request_token')) {
            
            $request_token = [
                'token'  => Session::get('oauth_request_token'),
                'secret' => Session::get('oauth_request_token_secret'),
            ];
            
            Twitter::reconfig($request_token);
            
            $oauth_verifier = false;
            
            if (Input::has('oauth_verifier')) {
                
                $oauth_verifier = Input::get('oauth_verifier');
            }
            
            // getAccessToken() will reset the token for you
            $token = Twitter::getAccessToken($oauth_verifier);
            
            if (!isset($token['oauth_token_secret'])) {
                
                return Redirect::route('twitter.login')->with('flash_error', 'We could not log you in on Twitter.');
            }
            
            $credentials = Twitter::getCredentials();
            
            if (is_object($credentials) && !isset($credentials->error)) {
                
                Session::put('access_token', $token);
                
                return Redirect::route('twitter_page')->with('flash_notice', 'Congrats! You\'ve successfully signed in!');
            }
            
            return Redirect::route('twitter.error')->with('flash_error', 'Crab! Something went wrong while signing you up!');
        }
    }

Making the tweet:

    //Making a post to the logged in User Twitter page
    public function postTweet(Request $request) {
        
        // Validate input before making post...
        $this->validate($request, [
            'post' => 'required',
        ]);
        
        // The post is valid, make tweet...
        $post = Twitter::postTweet(array(
            'status' => $request->post, 
            'format' => 'json',
        ));
        
        //Check if post is posted
        if ($post) {
            return back()
                ->with('success', 'Tweet successfully Posted.');
        } else {
            return back()
                ->withInput()
                ->with('error', 'There was a problem making the Tweet. Try again');
        }

    }

i'm getting Class 'App\Http\Controllers\Input' not found error when I authorized twitter to make post on my behalf. I tried use Illuminate\Support\Facades\Input; according to [Stack Overflow] (http://stackoverflow.com/questions/31696679/laravel-5-class-input-not-found) but the error was resolved.

Is there a better way of doing it or I'm missing something?

Answers and suggestions are highly welcome and appreciated. Thanks

9th December, 2016

nanpaul68 left a reply on TokenMismatchException In Compiled.php Line 2927: • 7 months ago

You'd have to add {{ csrf_field() }} or

in your form if you are using HTML form or better still...

18th November, 2016

nanpaul68 started a new conversation Two Factor Authentication • 8 months ago

hi, i'm trying to implement a two factor authentication in Laravel 5.3 based on a tutorial from "https://www.sitepoint.com/2fa-in-laravel-with-google-authenticator-get-secure/?utm_source=sitepoint&utm_medium=relatedsidebar&utm_term=web".

but i'm get an error:

ErrorException in Google2FAController.php line 58: App\Http\Controllers\Controller and Illuminate\Foundation\Validation\ValidatesRequests define the same property ($validatesRequestErrorBag) in the composition of App\Http\Controllers\Google2FAController. This might be incompatible, to improve maintainability consider using accessor methods in traits instead.

Class was composed. Could it be a compatibility issue? how can i go about solving this problem?

11th November, 2016

nanpaul68 started a new conversation Twitter Streaming Api • 8 months ago

Hi, I'm trying use twitter streaming api in my laravel app, I've followed tutorial from "https://scotch.io/tutorials/how-to-process-tweets-in-real-time-with-laravel", i have already set up all the necessary keys and tokens from twitter and the app is able to connect to twitter via console but I'm getting an error .

ErrorException Use of undefined constant TWITTER_CONSUMER_KEY - assumed 'TWITTER_CONSUMER_KEY' after the connection. any usefully suggestion?

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.