WPS2

WPS2

Member Since 3 Years Ago

Experience Points 1,430
Experience Level 1

3,570 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 4
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

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

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

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

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    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 Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

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

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

11 Jan
3 years ago

WPS2 left a reply on How To Conditionally Redirect Authenticated Users?

@thomaskim I need to redirect to login page if a guest user try to access the verification page. that's why I have added that 'verification' route to the auth group. verification page is to enter the verification code. Users should be sign in to the system to enter the verification code.

WPS2 left a reply on How To Conditionally Redirect Authenticated Users?

@mercuryseries isn't their easy way to check whether user has verified email or not at routes.php page?

WPS2 left a reply on How To Conditionally Redirect Authenticated Users?

@snapey redirect ('/verification') display a link for user to confirm their email address

WPS2 started a new conversation How To Conditionally Redirect Authenticated Users?

Hi All,

I am needing to redirect all requests from authenticated users who do not have verified their email address to '/verification' URI. Only authenticated( signed in) users have access to '/verification' URI.

I am getting the "This webpage has a redirect loop" error message when I update Authenticate.php Middleware file as follows.

    public function handle($request, Closure $next)
    {
        if ($this->auth->guest()) {
            if ($request->ajax()) {
                return response('Unauthorized.', 401);
            } else {
                return redirect()->guest('/');
            }
        }if (! $this->auth->user()->email_verified) {
            return redirect()->guest('/verification');
        }

        return $next($request);
    }

my routes.php has following validation

Route::group(['middleware' => 'auth'], function () {
    Route::get('/verification', 'Auth\AuthController@emailVerification');

    ... more code goes here

}

How can I do a conditional redirect to authenticated users in Laravel 5.1?

appreciate any help

Regards, Chandana

01 Nov
3 years ago

WPS2 left a reply on Laravel Deployment

@Shahin yes i did add the following lines to /etc/apache2/sites-available/000-default.conf file and now all routes are working fine. :)

<Directory "/var/www/html">
    AllowOverride All
</Directory>
31 Oct
3 years ago

WPS2 left a reply on Laravel Deployment On AWS EC2 Ubuntu 14.04

@Snapey it worked. i think something wrong with my mod_rewrite module. I added the following lines to /etc/apache2/sites-available/000-default.conf file and now all routes are working fine. :)

<Directory "/var/www/html">
    AllowOverride All
</Directory>

thanks again for your help.

WPS2 started a new conversation Laravel Deployment On EC2 Ubuntu 14.04

Hi All I am trying to deploy laravel 5.1 project on AWA EC2 cloud server and having an issue with the my laravel web site route URLs.

I ran following command 2 configure the EC2 ubuntu 14.04 LTS server.

sudo apt-get install apache2
sudo apt-get install mysql-server php5-mysql
sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt
sudo apt-get install php5 php-pear
sudo apt-get install curl php5-curl php5-cli git
sudo a2enmod rewrite
sudo php5enmod mcrypt
sudo service apache2 restart
sudo chmod -R 777 storage

it loads the /var/www/html/mynewhost/resources/views/auth/login.blade.php template as the home page. So I think Route::get('/', 'Auth\AuthController@getLogin') route is working.

but i am getting the following error when I try access any other route URLs. (eg. www.mynewhost.com/register)

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /register was not found on this server.</p>
<hr>
<address>Apache/2.4.7 (Ubuntu) Server at xxxx.ap-southeast-2.compute.amazonaws.com Port 80
</address>
</body></html>

I have changed the apache route URL to the public folder of my laravel project. Also I tried 2 enable the following virtual host file while the apache root is /var/www/html, but still got the same error.

<VirtualHost *:80>  
    ServerAdmin webmaster@mynewhost.com 
    DocumentRoot /var/www/html/mynewhost/public
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined 
</VirtualHost>

sudo a2dissite mynewhostl.com.conf
sudo service apache2 reload
sudo service apache2 restart

do I need to grant any permision to my laravel project folder?

appriciate any help.

PS. this is a duplicate post of https://laracasts.com/discuss/channels/laravel/laravel-deployment

WPS2 left a reply on Laravel Deployment

@Snapety it's loading the home page.

this is my default 000-default.htaccess file.

<VirtualHost *:80>
        ServerAdmin webmaster@mynewhost.com
        DocumentRoot /var/www/html/mynewhost/public
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Also I tried 2 enable the following virtual host file but still got the same error.

<VirtualHost *:80>  
    ServerAdmin webmaster@mynewhost.com 
    DocumentRoot /var/www/html/mynewhost/public
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined 
</VirtualHost>

WPS2 left a reply on Laravel Deployment

@Shahin stackoverflow is also a good place. I should have tried that as well

WPS2 left a reply on Laravel Deployment

i am sure there is a nice guy here who can help me with this:). its already took my 2 days there are lot to learn

WPS2 left a reply on Laravel Deployment

hi all

I just notice that my .env file has the app_env variable set to local. please see the below for the same.

APP_ENV=local
APP_DEBUG=true

do i need to change this?

WPS2 left a reply on Laravel Deployment

@Shahin thanks mate.

Hi Guys

I am still having the issue is the route URLs. I get the following error when I try access any route URL but my home page is working correctly.

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /register was not found on this server.</p>
<hr>
<address>Apache/2.4.7 (Ubuntu) Server at xxxxxxxxx.ap-southeast-2.compute.amazonaws.com Port 80
</address>
</body></html>

I have changed the apache route URL to the public folder of my laravel project. Also I tried 2 enable the following virtual host file but still got the same error.

<VirtualHost *:80>
        ServerName 192.168.0.6
        DocumentRoot /var/www/html/mysite/public

        <Directory /var/www/html/mysite/public>
            AllowOverride All
            Require all granted
        </Directory>
</VirtualHost>

and granted the permission using following.

sudo chmod 777 -R mysite/
sudo chmod 777 -R mysite/*

do I need to grant any permision to my laravel project folder?

WPS2 left a reply on Laravel Deployment

@Shahin I tried it with the GET, but its still not working

new routes.php


Route::get('/login', function () {
    return view('index');
});

Route::get('/register', function () {
return 1;
});

// Authentication routes...
Route::get('/', 'Auth\AuthController@getLogin');
Route::post('/', 'Auth\AuthController@postLogin');
Route::get('logout', 'Auth\AuthController@getLogout');

// Registration routes...
Route::get('register1', 'Auth\AuthController@getRegister');
Route::post('register1', 'Auth\AuthController@postRegister');

this is the error page

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /register was not found on this server.</p>
<hr>
<address>Apache/2.4.7 (Ubuntu) Server at ec2-52-64-70-41.ap-southeast-2.compute.amazonaws.com Port 80
</address>
</body></html>

WPS2 left a reply on Laravel Deployment

@yes its working fine. I thought there is no registration routes but its there

WPS2 left a reply on Laravel Deployment

@Shahin ah no. its correct. this is with the registration routes

Route::get('/login', function () {
    return view('index');
});

// Authentication routes...
Route::get('/', 'Auth\AuthController@getLogin');
Route::post('/', 'Auth\AuthController@postLogin');
Route::get('logout', 'Auth\AuthController@getLogout');

// Registration routes...
Route::post('register', 'Auth\AuthController@postRegister');

WPS2 left a reply on Laravel Deployment

@Shahin I think there is an error in my routes :(

WPS2 left a reply on Laravel Deployment

@Shahin I use the basic controllers not the implicit contollers

Route::get('/login', function () {
    return view('index');
});

// Authentication routes...
Route::get('/', 'Auth\AuthController@getLogin');
Route::post('/', 'Auth\AuthController@postLogin');
Route::get('logout', 'Auth\AuthController@getLogout');

WPS2 left a reply on Laravel Deployment

@Shahin sorry I ddidn't understand what do you mean by link systax and you are asking how i am linking css/js files. to answer your question, there is no link. its a form post as follows.

            <div class="col-md-4">
              <div class="block">
                <h3><i class="fa fa-user-plus"></i> Registration</h3>
                <form id="registration" name="registration" action="/register" method="post">
                    {!! csrf_field() !!}
                  <label for="username">User Name</label>
                  <input id="username" name="username" type="text" class="form-control" placeholder="User name" value="test">
                  <label for="password">Password</label>
                  <input id="password" name="password" type="password" class="form-control" placeholder="Password" value="test12">
                  <label for="password_confirmation">Confirm Password</label>
                  <input id="password_confirmation"  name="password_confirmation" type="password" class="form-control" placeholder="Confirm Password" value="test12">
                  <label for="email">Email</label>
                  <input id="email" name="email" type="email" class="form-control" placeholder="Email Address" value="test@gmail.com">
                  <label for="sex">I am a </label>
                    {!! Form::select('sex', Config::get('constants.sex'), old('sex_id') ? '' : '', array('class' => 'form-control')) !!}
                  <label for="dob">Date of Birth</label>
                  <input id="dob" name="dob" type="text" class="form-control datepicker" placeholder="Date of Birth" readonly value="1981-Feb-04">
                  <label for="country">Country</label>
                    {!! Form::select('country', Config::get('constants.country'), old('country_id') ? '' : '14',array('class' => 'form-control')) !!}
                  <button type="submit" class="btn">Sign Up</button><br>
                  By continuing, you're confirming that you've read and agree to our <a>Terms and Conditions</>, <a>Privacy Policy</a> and <a>Cookie Policy</a>
              </form>
              </div>
            </div>

WPS2 left a reply on Laravel Deployment

@Shahin thanks for your quick reply. I have used the same master page in my home page/login page blade template and it's working fine. so do you think still I need to change the this syntax?

WPS2 left a reply on Laravel Deployment

@Shahin I am using the following syntax to link the css/js files within blade templats. But actually my main issue is the routes URLs. Even i get the "Not Found, The requested URL /register was not found on this server" error when I enter the www.mynewhost.com/register from the address bar though my home page is working.

<link href="/css/imageupload.css" rel="stylesheet">
<script src="/js/jquery.cookie.js"></script>

WPS2 left a reply on Laravel Deployment

@Snapey thanks for the quick response. mynewhost.com home page is loading but the the route URLs are not work. i.e. mynewhost.com/register

WPS2 left a reply on Laravel Deployment

hi guys,

thanks you all for the replies. I couldn't get it worked on my local server. So I tried on deploy 1 web site on my live amazon ec2 cloud server and now I am getting a different error message.

It's load the home page, but the route urls are not working. I gets the "Not Found, The requested URL /register was not found on this server" error message when I try to navigate to www.mysite.com/register or http://************.ap-southeast-2.compute.amazonaws.com/register

I changed the apache root directory to laravel public folder and this is what i have in my /etc/apache2/sites-available

<VirtualHost *:80>  
    ServerAdmin webmaster@mysite.com 
    DocumentRoot /var/www/html/mysite/public
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined 
</VirtualHost>

appreciate any help.

29 Oct
3 years ago

WPS2 left a reply on Laravel Deployment

thanks for the reply

i ran following command.

echo "ServerName localhost" | sudo tee /etc/apache2/conf-available/fqdn.conf

my server name is localhost

but my etc/host.conf file is empty as follows

'''

The "order" line is only used by old versions of the C library.

order hosts,bind multi on '''

WPS2 left a reply on Laravel Deployment

any thoughts ?

WPS2 started a new conversation Laravel Deployment

Hi Guys,

I have couple of project that I am planning to deploy on amazon ec2 cloud server. As i have two project, i cannot make the laravel "public" folder the root directory in the settings. is there a better way to deploy 2 laravel projects on same web server?

I am going to deploy on apache web server ( LAMP server ) on ubuntu 14.04. what is the best web server to deploy laravel project? is Nginx better then Apache?

Thanks

11 Oct
3 years ago

WPS2 left a reply on Update Using API/AJAXs

@ohffs thanks. appreciate your help

WPS2 left a reply on Update Using API/AJAXs

@ohffs Thanks for your help. I did implement the X-CSRF-TOKEN token and the update is working fine.

But it's keep getting the same token every time even after I sign out and sign in again. Do we need to keep the same token till the user sign out or till his session expired?

Is it possible to regenerate the token every time when the use logs in to the system?

10 Oct
3 years ago

WPS2 left a reply on Update Using API/AJAXs

@ohffs I was going to implement the API inside the main app

WPS2 left a reply on Update Using API/AJAXs

May be I do not want to use the APIs at all.

may be I can use the my update route url (/profile/update/{profiledata} in my ajax call.

I will give it a go. Thanks again

WPS2 left a reply on Update Using API/AJAXs

@ohffs thanks for the great video. its really and easy to with api/ajax with Laravel

But may be I was not very clear with explaining my issue. That demo does not work with authentication.

I want to authenticate those ajax posts. I do not want to prompt user for the username/password if they are already logged in to the web site. And only the logged in user should be able to update his profile the api post.

WPS2 started a new conversation Update Using API/AJAXs

Sorry if this is a real Newb Question and even this may be not related to the Laravel. I have googled for hours and still I could't find how should I implement this. I can do some trial and error learning thing, but I need to understand what is the real login behind this.

I am relatively new to Laravel and still working on my first Laravel project using Laravel 5.1 . I have done the user authentication using laravel built-in AuthController authentication. Now users can login to system and they can browse the system without an any issue.

But I am going to implement some user updates using API and ajax posts. My question is how can I authenticate those ajax posts. I do not want to prompt user for the username/password if they are already logged in and also they should not be able to perform update using API if they are not logged in to the system. Further more I need to redirect them to login page if their session is expired (I can do this with return the status, but should be able to access the same web session for validation).

How can I implement this. Appreciate any help.

07 Oct
3 years ago

WPS2 left a reply on Real-time Laravel Without Redis

@NerdMonkey

I was also looking for similar app and found this on github, https://github.com/guilhermeslk/laravel-realtime-chat

this may help you.

WPS2 left a reply on Queued Event Which Has Implemented ShouldQueue Interface Is Not Working Asynchronously

Hi Guys

I was in the wrong impression that those drivers are paid services. I am looking in to redis and beanstalkd driver. I think I would probably use the redis as I am planning to add real time chat option using websockets.

Thanks again for your help.

WPS2 left a reply on Queued Event Which Has Implemented ShouldQueue Interface Is Not Working Asynchronously

@jekinney Thanks you very much.

Then best option is for me to remove my events and move those events to code base isnt it?

WPS2 left a reply on Queued Event Which Has Implemented ShouldQueue Interface Is Not Working Asynchronously

@jekinney

I was thinking to use the same database driver on production server as I am not a big fan of 3rd party services. And also I am not going to make any profit from this web site. Therefore I am not in a position to pay for the 3rd services.

is there any issue using the Database driver on production server?

WPS2 left a reply on Queued Event Which Has Implemented ShouldQueue Interface Is Not Working Asynchronously

Hi Guys

Thanks you all for the quick response. is there any known performance issue with Database driver?

WPS2 left a reply on Queued Event Which Has Implemented ShouldQueue Interface Is Not Working Asynchronously

@jekinney is that mean the default driver which has already configured in Laravel 5.1 does not run asynchronously?

WPS2 left a reply on Queued Event Which Has Implemented ShouldQueue Interface Is Not Working Asynchronously

@bobbybouwmann Thank you very much for your quick reply. This is really really active forum as I have read in the web.

Please see my updated post. I have removed some code blocks to make it easy to understanding.

I am assuming that I am using the default sync drive. this is what I have in config\queue.php file

'default' => 'sync',

do i need to any changes to config\queue.php file?

WPS2 started a new conversation Queued Event Which Has Implemented ShouldQueue Interface Is Not Working Asynchronously

Hi All,

Couple of weeks ago I started learning Laravel and I started a project Laravel 5.1

I have subscribed event configured to fire when raise auth.login and auth.logout event. This has implement the ShouldQueue interface, but the events still seems to be run synchronously. Please see my code below. I have added sleep(20) inside the event in order to test whether it is working asynchronously, but the loin page waits 20 seconds before it is redirected to next page.

Here is my complete code related to Events.

Listeners\UserEventHandler.php

<?php

namespace App\Listeners;

use App\Events\UserEvent;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;

use Carbon\Carbon;
use App\OnlineUser;

class UserEventHandler implements ShouldQueue
{
    /**
     * Handle user login events.
     */
    public function onUserLogin($event) 
    {
        sleep(5);
        $event->last_login = Carbon::now();
        $online = $event->Online;
        if (is_null($online)) {
            $online = new OnlineUser;
            if ($online === null) {
            }
            $online-> status = (is_null($event->profileimage_id) ? 4 : 1);
            $event->Online()->save($online);
            $event->load('Online');
        } 
        else 
        {
            $online->status = (is_null($event->profileimage_id) ? 4 : 1);
            $online->save();
            /* not required to update the timestamp if user is inactive ( doesnt have a profile pic)
            if($online->isDirty())
            {
                $online->save();
            }
            else
            {
                $online->touch();
            }
            */
        }
        $online = $event->Online;
        $event->save();
    }

    /**
     * Handle user logout events.
     */
    public function onUserLogout($event) 
    {
        $online = $event->Online;
        if (!is_null($online)) {
            $online->status = (is_null($event->profileimage_id) ? 4 : 3);
            if($online->isDirty())
            {
                $online->save();
            }         
        }        
    }

    /**
     * Register the listeners for the subscriber.
     *
     * @param  Illuminate\Events\Dispatcher  $events
     * @return array
     */
    public function subscribe($events)
    {
        $events->listen(
            'auth.login',
            'App\Listeners\UserEventHandler@onUserLogin'
        );

        $events->listen(
            'auth.logout',
            'App\Listeners\UserEventHandler@onUserLogout'
        );
    }
}

Providers\EventServiceProvider.php


<?php

namespace App\Providers;

use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;

class EventServiceProvider extends ServiceProvider
{
    /**
     * The event listener mappings for the application.
     *
     * @var array
     */
    protected $listen = [
        
    ];

    /**
     * The subscriber classes to register.
     *
     * @var array
     */
    protected $subscribe = [
        'App\Listeners\UserEventHandler',
    ];

    /**
     * Register any other events for your application.
     *
     * @param  \Illuminate\Contracts\Events\Dispatcher  $events
     * @return void
     */
    public function boot(DispatcherContract $events)
    {
        parent::boot($events);

        //
    }
}

Have I done anything wrong here. Appreciate any Help