dk4210

dk4210

Member Since 1 Year Ago

Experience Points 14,920
Experience
Level
Lessons Completed 122
Lessons
Completed
Best Reply Awards 0
Best Answer
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.

27 Sep
1 month ago

dk4210 started a new conversation MVC Routing Question

Hello Guys,

I did a tutorial on creating an MVC from scratch (To learn ONLY) and it works great to load one page. I want to add a router to it. I'm trying to figure out the best approach.

My structure is

++controller - Controller.php ++model - Book.php - Model.php ++view - booklist.php - viewbook.php

index.php

Here's my index


<?php

include_once("controller/Controller.php");

$controller = new Controller();

$controller->invoke();

Here's my controller

<?php

include_once("model/Model.php");


class Controller {


    public $model;

    public function __construct()
    {
        $this->model = new Model();
    }

    public function invoke()
    {
        if (!isset($_GET['book'])){

            // no special book is requested. Lets show all available books

            $books = $this->model->getBookList();
            include 'view/booklist.php';

        }else{
             // show the requested book
             $book = $this->model->getBook($_GET['book']);
             include 'view/viewbook.php';

        }
    }

}

It goes to the booklist and viewbook pages just fine , but what if I want to add a CD area for example like cdlist and viewcd?

Thanks for your help.

27 Jul
3 months ago

dk4210 started a new conversation Bootstrap-select Crazy Issue

Hello Guys,

Hopefully some one can help on this. It's driving me mad.

First of all I'm using the library called bootstrap select. What I'm trying to do is add a "live search" feature to a drop down menu that's populated by js find the id and inject the html into it. like this

JS File

    $('#manual_appointment_practice').html(practiceList);

I also have this in my JS file to initialize the select library

 $('#manual_appointment_practice').selectpicker();

In my html file I have this

<select class="form-control" name="manual_appointment_practice" id="manual_appointment_practice" data-live-search="true">                                                                     
</select>

Its showing the names in the drop down, but its creating

  • like this, but I need

    <li data-original-index="2"><a tabindex="0" class="" data-tokens="null" role="option" aria-disabled="false" aria-selected="false"><span class="text">100 Eye Place</span><span class="glyphicon glyphicon-ok check-mark"></span></a>
    </li>
    

    If I do console.log on the practiceList I receive all the info like this

    <option value="0">Select Practice</option><option value="-1">Not listed</option><option value="2573" data-manually_created="1">100 Eye Place</option>
    

    Here's a link to the library https://silviomoreto.github.io/bootstrap-select/examples/#live-search

    Any help would be appreciated.

    Thanks, Dan

  • 22 Jun
    4 months ago

    dk4210 left a reply on Laravel Method Execution Time Limits

    Yea for a long term fix, you're right that may be the best idea but short term I was wondering what the limits would be.

    dk4210 started a new conversation Laravel Method Execution Time Limits

    Hello guys,

    I'm trying to run a large report ( via the UI) and when I run it, basically it times out.

    Here's the setting I have in the method

    ini_set('max_execution_time', 3600); ini_set('memory_limit', '512M');

    Is it safe to increase this more or what is the limits you think? I know its based on the server we have right?

    Thanks in advance.

    19 Jun
    4 months ago

    dk4210 started a new conversation Model Eloquent Question

    Hello Guys,

    I'm trying to understand how the model Eloquent queries work.

    I have this method for example

    
    public function practice()
        {
          return $this->belongsTo('dev\Models\Practice')->withTrashed();
        }
    
    

    If I do this

    public function practice()
        {
        // return $this->belongsTo('dev\Models\Practice');
       dd($this->belongsTo('dev\Models\Practice')->toSql());
        }
    
    

    I get this

    "select * from `practices` where `practices`.`deleted_at` is null"
    
    

    I'm basically trying to get the query to just say

    "select * from `practices`"
    
    

    I don't understand how calling an entire model "Practice" outputs that query.

    There's many methods in the practice model. Can some one clarify?

    08 Jun
    5 months ago

    dk4210 started a new conversation Calling A Method Variable

    I have a question about calling a method variable.

    I have the following method

    private function getDeactivatedInfo($report_fields){
            $deactivate_data = array();
            $report_fields = ReportField::where('report_name', 'accounting_deactivate')->get(['name', 'display_name'])->toArray();
    
            return $report_fields;
            
        }
    

    and I have the following

    $report_list = self::getDeactivatedInfo($report_fields); dd($report_list);

    I get an error of undefined variable. Can some one tell me why?

    07 Jun
    5 months ago

    dk4210 left a reply on WithTrashed Isn't Working

    my model is called practice.php and I guess it uses the softDelete trait. Not sure. I've never used traits before.

    Thanks!

    dk4210 left a reply on WithTrashed Isn't Working

    You mean include it in the model page?

    at the top of the page I included. use Illuminate\Database\Eloquent\SoftDeletes;

    and within the class

    use SoftDeletes;

    dk4210 started a new conversation WithTrashed Isn't Working

    Hello Guys,

    Can some one help me out to figure out why withTrashed isn't displaying the soft deletes.

    in my model I have this

      public function practiceNetwork()
        {
            return $this->hasMany('dev\Models\PracticeNetwork');
        }
    
    

    I tried this

     public function practiceNetwork()
        {
            return $this->hasMany('myocuhub\Models\PracticeNetwork')->withTrashed();
        }
    
    

    I get the error message

     BadMethodCallException in Builder.php line 2405: Call to undefined method Illuminate\Database\Query\Builder::withTrashed()
    
    

    In my model I also have s function that has this

     $query = self::query()->withTrashed();
     $query->where('id', $practice_id);
     $query->with('practiceNetwork.network');
     
    

    But the problem is it will only show the records with a deleted_at value of NULL

    Any ideas.

    Thanks!

    30 May
    5 months ago

    dk4210 left a reply on PhpMailer

    I found out when I set $mail->SMTPDebug = true That you can launch developer tools in your browser and watch the network requests and then click on response, it will show you the debug info. Wish I would have known this 2 days ago. It would have made my life much easier.

    My problem ended up being the smtp provider we are using blocked our ip address. The debug info even tells me that to contact them and have it unblocked.

    Hope this helps some one in the future.

    29 May
    5 months ago

    dk4210 left a reply on PhpMailer

    Guys I cant do config:cache or clear:cache on production. Thats what got me in trouble to start with.

    I see my logs but it just gives me the overall reason of failure, for me it is

    How can I see results like this with laravel? This is an example of what some one done below. Trying to see how I can spit out the entire action.

    https://github.com/PHPMailer/PHPMailer/issues/1025

    017-04-13 10:33:55 SERVER -> CLIENT: 220 lecas.av.it.pt Microsoft ESMTP MAIL Service ready at Thu, 13 Apr 2017 11:33:53 +0100
    2017-04-13 10:33:55 CLIENT -> SERVER: EHLO sigest.av.it.pt
    2017-04-13 10:33:55 SERVER -> CLIENT: 250-lecas.av.it.pt Hello [192.168.86.40]
    250-SIZE 37748736
    250-PIPELINING
    250-DSN
    250-ENHANCEDSTATUSCODES
    250-STARTTLS
    250-X-ANONYMOUSTLS
    250-AUTH NTLM
    250-X-EXPS GSSAPI NTLM
    250-8BITMIME
    250-BINARYMIME
    250-CHUNKING
    250 XRDST
    2017-04-13 10:33:55 CLIENT -> SERVER: STARTTLS
    2017-04-13 10:33:55 SERVER -> CLIENT: 220 2.0.0 SMTP server ready
    2017-04-13 10:33:55 CLIENT -> SERVER: EHLO sigest.av.it.pt
    2017-04-13 10:33:55 SERVER -> CLIENT: 250-lecas.av.it.pt Hello [192.168.86.40]
    250-SIZE 37748736
    250-PIPELINING
    250-DSN
    250-ENHANCEDSTATUSCODES
    250-AUTH NTLM LOGIN
    250-X-EXPS GSSAPI NTLM
    250-8BITMIME
    250-BINARYMIME
    250-CHUNKING
    250 XRDST
    2017-04-13 10:33:55 SMTP Error: Could not authenticate.
    2017-04-13 10:33:55 CLIENT -> SERVER: QUIT
    2017-04-13 10:33:55 SERVER -> CLIENT: 221 2.0.0 Service closing transmission channel
    2017-04-13 10:33:55 SMTP connect() failed.
    

    Thanks, Dan

    dk4210 left a reply on PhpMailer

    This is the oddest problem. The same code is on UAT as Production but only have an issue with Production. Anyone have any more ideas on what it could be?

    27 May
    5 months ago

    dk4210 left a reply on PhpMailer

    Can you please elaborate on this?

    "mail driver to log for troubleshooting"

    dk4210 left a reply on PhpMailer

    I'm getting an authorization failed error. The same code is on UAT and it works. Didn't know about swiftmailer.

    26 May
    5 months ago

    dk4210 started a new conversation PhpMailer

    Any one here and expert with PHP mailer. I'm having a hard time getting it to work. I deployed some changes to production and the changes required me to run

    php artisan config:cache and php artisan cache:clear
    
    ``
    Since all my variables are controlled by .env , it some how started failing. I statically set the values and it still doesn't work. Any one know what maybe happening?
     
    
    
    
    24 May
    5 months ago

    dk4210 left a reply on Cache Help!

    I ended up statically setting vars. It woked. Don't understand why the cache has anything to do with the path to env.

    dk4210 left a reply on Cache Help!

    A couple of API settings. Like mandrill. This is the code

    $this->mandrill = new Mandrill(env('MANDRILL_SECRET'));

    It wont read the api key for some reason.

    dk4210 started a new conversation Cache Help!

    Hello Guys, I'm working a legacy application laravel 5.2 and modified a file under config on my local. I ran the command "php artisan config:cache" and it worked great. I pushed it to production and ran the same command and now it can't find the api settings. I tried to do a cache:clean but no luck. Any ideas? I need help pretty bad here. I broke the application.

    17 May
    5 months ago

    dk4210 started a new conversation Gulp On Production

    Hello Guys,

    I have a question in regards to running gulp on production or UAT. If I run gulp on my local and commit the branch do I need to run it again on UAT or Prod?

    Thanks!

    22 Apr
    6 months ago

    dk4210 left a reply on Passing Array From Controller And View In Blade

    That worked!

    Thanks, Dan

    dk4210 left a reply on Passing Array From Controller And View In Blade

    Thanks for the info. How would display it on the page without var_dump?

    maybe with the {{ }}

    dk4210 started a new conversation Passing Array From Controller And View In Blade

    Hello Guys,

    I want to display only certain values from an array. I can't seem to make it work.

    This is my controller ( The response comes from a zillow api call )

     return view('listhome',compact('response'));
    
    

    If I add this in blade (listhome)

     @php
          echo "<pre>";
            var_dump($response);
           echo "</pre>";
        @endphp
    
    

    i see this

    array(1) {
      ["results"]=>
      array(1) {
        ["result"]=>
        array(17) {
          ["zpid"]=>
          string(8) "1433324"
          ["links"]=>
          array(4) {
            ["homedetails"]=>
            string(85) "https://www.zillow.com/homedetails/an address/14673332_zpid/"
            ["graphsanddata"]=>
            string(100) "http://www.zillow.com/homedetails/an address/14673332_zpid/#charts-and-data"
            ["mapthishome"]=>
            string(42) "http://www.zillow.com/homes/146732423_zpid/"
            ["comparables"]=>
            string(48) "http://www.zillow.com/homes/comps/146324432_zpid/"
          }
          ["address"]=>
          array(6) {
            ["street"]=>
            string(18) "101 test street"
            ["zipcode"]=>
            string(5) "30964"
            ["city"]=>
            string(7) "Albany"
            ["state"]=>
            string(2) "NY"
            ["latitude"]=>
    

    How can I get it to just display the street?

    Thanks in advanced.

    11 Apr
    7 months ago

    dk4210 left a reply on NPM Install [email protected]

    I fixed the issue. After trying everything I got it to work. I ended up re cloneing the project from the repo and downgrading the Node and NPM version to an older one

    node - v6.10.2 npm - 3.10.10

    I then ran NPM install and composer install.

    In my case, that worked because the application that I'm working on is based on Laravel 5.2 and I guess the Node version I had was to updated I guess.

    dk4210 started a new conversation NPM Install [email protected]

    Hello Guys,

    For some reason everytime I do an NPM install it gets stuck on installing the node-sass. The project doesn't even use node-sass. This is the error.

    [email protected] install C:\development\node_modules\gulp-sass\node_modules\node-sass
    > node scripts/install.js
    
    Downloading binary from https://npm.taobao.org/mirrors/node-sass/v3.13.1/win32-x64-57_binding.node
    Cannot download "https://npm.taobao.org/mirrors/node-sass/v3.13.1/win32-x64-57_binding.node":
    
    HTTP error 404 Not Found
    
    Hint: If github.com is not accessible in your location
          try setting a proxy via HTTP_PROXY, e.g.
    
          export HTTP_PROXY=http://example.com:1234
    
    or configure npm proxy via
    
          npm config set proxy http://example.com:8080
    
    > [email protected] install C:\development\node_modules\uws
    > node-gyp rebuild > build_log.txt 2>&1 || exit 0
    
    
    > [email protected] postinstall C:\development\node_modules\gulp-sass\node_modules\node-sass
    > node scripts/build.js
    
    

    Any way to stop it from trying to install this?

    Thanks in advance.

    29 Mar
    7 months ago

    dk4210 left a reply on How I Can Get "admin" Auth User Information

    When you "not working" can you tell me what you receive? An error or just empty vars?

    dk4210 left a reply on Access Array In Object

    What do you see when you do dd($company)

    dk4210 left a reply on Dusk Chrome Driver Error - Unknown Error: Call Function Result Missing 'value'

    Worked like a charm! Can't thank you enough!

    28 Mar
    7 months ago

    dk4210 left a reply on Dusk Chrome Driver Error - Unknown Error: Call Function Result Missing 'value'

    not sure why it says "chromedriver=2.28.455520"

    dk4210 started a new conversation Dusk Chrome Driver Error - Unknown Error: Call Function Result Missing 'value'

    Hello Guys,

    I'm having a strange problem with the chrome driver for running tests. It's been working fine for months and all of a sudden i get an error when running my tests.

    Here's the error (simplified)

    Tests\Browser\Elements\LoginTest::testExample Facebook\WebDriver\Exception\UnknownServerException: unknown error: call function result missing 'value' (Session info: chrome=65.0.3325.181) (Driver info: chromedriver=2.28.455520 
    

    Here's the entire error message

    success: "Warning: TTY mode is not supported on Windows platform. PHPUnit 5.7.23 by Sebastian Bergmann and contributors. E 1 / 1 (100%) Time: 4.36 seconds, Memory: 12.00MB There was 1 error: 1) Tests\Browser\Elements\LoginTest::testExample Facebook\WebDriver\Exception\UnknownServerException: unknown error: call function result missing 'value' (Session info: chrome=65.0.3325.181) (Driver info: chromedriver=2.28.455520 (cc17746adff54984afff480136733114c6b3704b),platform=Windows NT 6.1.7601 SP1 x86_64) C:\xampp\htdocs\automation_team\vendor\facebook\webdriver\lib\Exception\WebDriverException.php:114 C:\xampp\htdocs\automation_team\vendor\facebook\webdriver\lib\Remote\HttpCommandExecutor.php:320 C:\xampp\htdocs\automation_team\vendor\facebook\webdriver\lib\Remote\RemoteWebDriver.php:535 C:\xampp\htdocs\automation_team\vendor\facebook\webdriver\lib\Remote\RemoteExecuteMethod.php:40 C:\xampp\htdocs\automation_team\vendor\facebook\webdriver\lib\Remote\RemoteWebElement.php:66 C:\xampp\htdocs\automation_team\vendor\laravel\dusk\src\Concerns\InteractsWithElements.php:169 C:\xampp\htdocs\automation_team\tests\Browser\Todaytest.php:33 C:\xampp\htdocs\automation_team\vendor\laravel\dusk\src\TestCase.php:91 C:\xampp\htdocs\automation_team\tests\Browser\Todaytest.php:63 ERRORS! Tests: 1, Assertions: 0, Errors: 1. ",
    

    The steps I've taken

    1. Upgraded chrome browser
    2. Updated the chrome driver to 2.27.544315
    3. Updated npm
    4. Ran composer update 5 ran npm update
    5. Viewed other sources

    Still no luck.

    Any one have any ideas?

    26 Mar
    7 months ago

    dk4210 started a new conversation Redirecting Users Based On Role

    Hello all,

    I'm trying to figure out how to redirect users based on their role. Currently all users just redirect to my-account. I would like the user to be directed to certain areas based on their role.

    Here's my controller (FrontEndController)

    getLogin method

    public function getLogin()
        {
            // Is the user logged in?
            if (Sentinel::check()) {
                return Redirect::route('my-account');
            }
            // Show the login page
            return view('login');
        }
    

    Heres the PostLogin method

    public function postLogin(Request $request)
        {
    
            try {
                // Try to log the user in
                if ($user=Sentinel::authenticate($request->only('email', 'password'), $request->get('remember-me', 0))) {
                    //Activity log for login
                    activity($user->full_name)
                        ->performedOn($user)
                        ->causedBy($user)
                        ->log('LoggedIn');
    
                   return Redirect::route("my-account")->with('success', trans('auth/message.login.success'));
                } else {
                   return redirect('/')->with('error', 'Email or password is incorrect.');
                   //return Redirect::back()->withInput()->withErrors($validator);
                }
    
            } catch (UserNotFoundException $e) {
                $this->messageBag->add('email', trans('auth/message.account_not_found'));
            } catch (NotActivatedException $e) {
                $this->messageBag->add('email', trans('auth/message.account_not_activated'));
            } catch (UserSuspendedException $e) {
                $this->messageBag->add('email', trans('auth/message.account_suspended'));
            } catch (UserBannedException $e) {
                $this->messageBag->add('email', trans('auth/message.account_banned'));
            } catch (ThrottlingException $e) {
                $delay = $e->getDelay();
                $this->messageBag->add('email', trans('auth/message.account_suspended', compact('delay')));
            }
    
            // Ooops.. something went wrong
            return Redirect::back()->withInput()->withErrors($this->messageBag);
        }
    

    The roles will be something like

    1 super admin
    2 admin
    3 traveler
    4 home owner
    

    Please advise on the best approach

    Thanks!

    25 Mar
    7 months ago

    dk4210 left a reply on Blade Check If User Is Logged In

    Figured it out. Looks like my auth is being controller by Sentinel so i did this

    @if(Sentinel::check())
                Logged in
            @else
                Not logged in
            @endif
    
    

    and it works

    dk4210 left a reply on Blade Check If User Is Logged In

    I know right. It's driving me insane! LOL

    dk4210 left a reply on Blade Check If User Is Logged In

    This code

    @if (auth()->guest())
     Guest         
    @else
            User
    @endif 
    

    displays guest logged in or not.

    dk4210 left a reply on Blade Check If User Is Logged In

    I'm using 5.5.34

    dk4210 left a reply on Blade Check If User Is Logged In

    Hmm no luck.

    added this

     @guest
            Guest       
           @endguest
            @auth
                  User        
            @endauth
    

    Saved then logged in and it says "Guest"

    dk4210 left a reply on Blade Check If User Is Logged In

    This is in my controller

     /**
         * get user details and display
         */
        public function myAccount(User $user)
        {
            $user = Sentinel::getUser();
            $countries = $this->countries;
            return view('user_account', compact('user', 'countries'));
        }
    

    dk4210 left a reply on Blade Check If User Is Logged In

    Yep. its in there. The header works fine. When I'm logged in i see a page called my-account. If I logout (by manually entering in "logout" in the browser) I can't see the page any more.

    dk4210 left a reply on Blade Check If User Is Logged In

    No errors that I see.

    Thanks!

    dk4210 left a reply on Blade Check If User Is Logged In

    This is the entire header

    <div class="header">
            <div class="container">
           <div class="row">
           <div class="col-md-8">            
        <img class="header_logo" src="{{ asset('images/logo.png') }}" alt="Homes" />
      </div>
      <div class="col-md-4">
    
            @guest
            <ol class="login-nav">
                <li><a href="#" data-toggle="modal" data-target="#login-modal">traveler login</a></li><span class="vl"></span>
                <li><a href="{{ url("login/owner") }}">homes owner login</a></li>
            </ol>
                <a href="{{ url("list-your-home") }}" class="btn">list your home</a>
            @endguest
            @auth
            <li><a href="{{ url("logout") }}">logout</a></li>
            @endauth
            
      </div>
    
          
      {{-- Start Modal --}}
    
      <div class="modal fade" id="login-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
            <div class="modal-dialog">
                    
                  <div class="loginmodal-container">
                        <button class="close" type="button" data-dismiss="modal" aria-hidden="true">x</button>
                       <h1><div class="login-txt">Login to Your Account</div></h1><br>
                       <!-- Notifications -->
                       <div id="notific">
                       @include('notifications')
                       </div>
                       <form action="{{ route('login') }}" class="omb_loginForm"  autocomplete="off" method="POST">
                        <input type="hidden" name="_token" value="{{ csrf_token() }}">
                        <div class="form-group {{ $errors->first('email', 'has-error') }}">
                            <label class="sr-only">Email</label>
                            <input type="email" class="form-control" name="email" placeholder="Email"
                                   value="{!! old('email') !!}">
                        </div>
                        <span class="help-block">{{ $errors->first('email', ':message') }}</span>
                        <div class="form-group {{ $errors->first('password', 'has-error') }}">
                            <label class="sr-only">Password</label>
                            <input type="password" class="form-control" name="password" placeholder="Password">
                        </div>
                        <span class="help-block">{{ $errors->first('password', ':message') }}</span>
                        <div id="remember-checkbox">
                            <label>
                                <input type="checkbox"> Remember Password
                            </label>
                        </div>
                        <input type="submit" class="loginmodal-submit" value="Log In">
                       {{--Don't have an account? <a href="{{ route('register') }}"><strong> Sign Up</strong></a>--}} 
                    </form>
                      
                    <div class="login-help">
                      <a href="#">Register</a> - <a href="#">Forgot Password</a>
                    </div>
                  </div>
              </div>
            </div>
    
      {{-- End Modal --}}
      
    </div>
    </div>
    <div class="navbar">
            <div class="container">
                <div class="row">
                    <div class="col-sm-12">
                        <nav>
                            <ul class="nav">
                                <li><a href="{{ url("/") }}" {!! (Request::is('/') ? 'class="active"' : '') !!}>home</a></li>
                                <li><a href="{{ url("aboutus") }}" {!! (Request::is('aboutus') ? 'class="active"' : '') !!}>about us</a></li>
                                <li><a href="{{ url("find-a-home") }}" {!! (Request::is('find-a-home') ? 'class="active"' : '') !!}>find a home</a></li>
                                <li><a href="{{ url("blog") }}" {!! (Request::is('blog') ? 'class="active"' : '') !!}>blog</a></li>
                                <li><a href="{{ url("testimonials") }}" {!! (Request::is('testimonials') ? 'class="active"' : '') !!}>testimonials</a></li>
                            </ul>
                        </nav>         
                    </div>
                </div>
            </div>
            <div class="navbar-inner">
                
            </div>
        </div>
    
    </div>
    
    
    
    <?php Request::is('/') ?>
    
    

    dk4210 left a reply on Blade Check If User Is Logged In

    Thanks for the reply. I replaced the code that you provided and still no luck. I tested by logging in and out and the options never changed.

    Thanks!

    dk4210 started a new conversation Blade Check If User Is Logged In

    Hello Guys,

    I want to display different options ( in blade) if a user is logged in or not. I can't seem to get it to work. I know the following is suppose to work, but it doesn't. It displays the logout no matter if I'm successfully logged in or not.

     @if (Auth::guest())
            <ol class="login-nav">
                <li><a href="#" data-toggle="modal" data-target="#login-modal">traveler login</a></li><span class="vl"></span>
                <li><a href="{{ url("login/owner") }}">homes owner login</a></li>
            </ol>
                <a href="{{ url("list-your-home") }}" class="btn">list your home</a>
            @else
            <li><a href="{{ url("logout") }}">logout</a></li>
            @endif
    

    Please advise.

    dk4210 left a reply on Error Response In Modal Without It Disappearing

    Perfect! that worked!

    Thank you!

    dk4210 left a reply on Error Response In Modal Without It Disappearing

    Still no luck. I added this at the bottom of the file

    <script>
    $( document ).ready(function() {
        @if (count($errors) > 0)
        $('#login-modal').modal('show');
      @endif
    });
    </script>
    

    dk4210 left a reply on Error Response In Modal Without It Disappearing

    I know the 1st option requires ajax. I think the second option would be best. It's kinda doing a page refresh cause when i click on login it tries to validate then refreshes the page. I would like for the modal to pop back up.

    dk4210 left a reply on Error Response In Modal Without It Disappearing

    As soon as i click on log in with the wrong credentials the modal disappears and when i click on log in again it displays the error message. I guess I would like for the modal to either stay and display the message or as the page reloads have the modal pop back up.

    dk4210 started a new conversation Error Response In Modal

    Hello Guys,

    I know that this question has been asked many times but I can't seem to get it right.

    I want to get to display the errors in the modal and not disappear after clicking on login.

    Here's the log in page

    <div class="header">
            <div class="container">
           <div class="row">
           <div class="col-md-8">            
        <img class="header_logo" src="{{ asset('images/hautelogo.png') }}" alt="Hautes Homes" />
      </div>
      <div class="col-md-4">
            <ol class="login-nav">
                    <li><a href="#" data-toggle="modal" data-target="#login-modal">traveler login</a></li><span class="vl"></span>
                    <li><a href="{{ url("login/owner") }}">haute homes owner login</a></li>
                </ol>
                <a href="{{ url("list-your-home") }}" class="btn">list your haute home</a>
      </div>
    
          
      <script>
            @if (count($errors) > 0)
            $('#login-modal').modal('show');
        @endif
      </script>
    
      
    
       {{-- Start Modal --}}
    
      <div class="modal fade" id="login-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
            <div class="modal-dialog">
                    
                  <div class="loginmodal-container">
                        <button class="close" type="button" data-dismiss="modal" aria-hidden="true">x</button>
                       <h1><div class="login-txt">Login to Your Account</div></h1><br>
                       <!-- Notifications -->
                       <div id="notific">
                       @include('notifications')
                       </div>
                       <form action="{{ route('login') }}" class="omb_loginForm"  autocomplete="off" method="POST">
                        <input type="hidden" name="_token" value="{{ csrf_token() }}">
                        <div class="form-group {{ $errors->first('email', 'has-error') }}">
                            <label class="sr-only">Email</label>
                            <input type="email" class="form-control" name="email" placeholder="Email"
                                   value="{!! old('email') !!}">
                        </div>
                        <span class="help-block">{{ $errors->first('email', ':message') }}</span>
                        <div class="form-group {{ $errors->first('password', 'has-error') }}">
                            <label class="sr-only">Password</label>
                            <input type="password" class="form-control" name="password" placeholder="Password">
                        </div>
                        <span class="help-block">{{ $errors->first('password', ':message') }}</span>
                        <div id="remember-checkbox">
                            <label>
                                <input type="checkbox"> Remember Password
                            </label>
                        </div>
                        <input type="submit" class="loginmodal-submit" value="Log In">
                       {{--Don't have an account? <a href="{{ route('register') }}"><strong> Sign Up</strong></a>--}} 
                    </form>
                      
                    <div class="login-help">
                      <a href="#">Register</a> - <a href="#">Forgot Password</a>
                    </div>
                  </div>
              </div>
            </div>
    
      {{-- End Modal --}}
      
    </div>
    </div>
    <div class="navbar">
            <div class="container">
                <div class="row">
                    <div class="col-sm-12">
                        <nav>
                            <ul class="nav">
                                <li><a href="{{ url("/") }}" {!! (Request::is('/') ? 'class="active"' : '') !!}>home</a></li>
                                <li><a href="{{ url("aboutus") }}" {!! (Request::is('aboutus') ? 'class="active"' : '') !!}>about us</a></li>
                                <li><a href="{{ url("find-a-home") }}" {!! (Request::is('find-a-home') ? 'class="active"' : '') !!}>find a haute home</a></li>
                                <li><a href="{{ url("blog") }}" {!! (Request::is('blog') ? 'class="active"' : '') !!}>blog</a></li>
                                <li><a href="{{ url("testimonials") }}" {!! (Request::is('testimonials') ? 'class="active"' : '') !!}>testimonials</a></li>
                            </ul>
                        </nav>         
                    </div>
                </div>
            </div>
            <div class="navbar-inner">
                
            </div>
        </div>
    
    </div>
    
    
    <?php Request::is('/') ?>
    

    Here's the controller/ method

     /**
         * Account sign in form processing.
         *
         * @return Redirect
         */
        public function postLogin(Request $request)
        {
    
            try {
                // Try to log the user in
                if ($user=  Sentinel::authenticate($request->only('email', 'password'), $request->get('remember-me', 0))) {
                    //Activity log for login
                    activity($user->full_name)
                        ->performedOn($user)
                        ->causedBy($user)
                        ->log('LoggedIn');
    
                    return Redirect::route("my-account")->with('success', trans('auth/message.login.success'));
                } else {
                   return redirect('/')->with('error', 'Email or password is incorrect.');
                   //return Redirect::back()->withInput()->withErrors($validator);
                }
    
            } catch (UserNotFoundException $e) {
                $this->messageBag->add('email', trans('auth/message.account_not_found'));
            } catch (NotActivatedException $e) {
                $this->messageBag->add('email', trans('auth/message.account_not_activated'));
            } catch (UserSuspendedException $e) {
                $this->messageBag->add('email', trans('auth/message.account_suspended'));
            } catch (UserBannedException $e) {
                $this->messageBag->add('email', trans('auth/message.account_banned'));
            } catch (ThrottlingException $e) {
                $delay = $e->getDelay();
                $this->messageBag->add('email', trans('auth/message.account_suspended', compact('delay')));
            }
    
            // Ooops.. something went wrong
            return Redirect::back()->withInput()->withErrors($this->messageBag);
        }
    

    Please advise.

    Thanks!

    28 Jan
    9 months ago

    dk4210 left a reply on React Async Validation

    That's correct I want to see if the package exists on the back end. Back end is going to be developed with Java ( I wish it was laravel). I'm trying to do the front end. If nothing else maybe fake it with a json file or something to prove it works.

    Thanks!

    dk4210 started a new conversation React Async Validation

    Hello All,

    Anyone have any experience with React / async validation? I'm trying to figure out how to do an async validation with JOI.

    I can do client side validation, but not sure how to add the async validation. I basically have a required field called package. I want it to server side validation onBlur to see if the package is taken. Can some one give me a hand?

    Here's what my code looks like

    'use strict';
    import axios from 'axios'
    import React, { Component } from 'react';
    import PropTypes from 'prop-types';
    import validation from 'react-validation-mixin';
    import strategy from 'joi-validation-strategy';
    import Joi from 'joi';
    import { Row, Col, Button,  ButtonDropdown, DropdownToggle, DropdownMenu, DropdownItem, Card, CardHeader, CardFooter, CardBody, Form, FormGroup, FormText, Label, Input,
    InputGroup, InputGroupAddon, InputGroupButton} from 'reactstrap';
    
     
    class Step1 extends Component {
     constructor(props) {
        super(props)
    
        // sets state of package name
        this.state = {
          packagename: props.getStore().packagename
          
        };
    
        this.validatorTypes = {
          packagename: Joi.string().required().min(3).label("The Package Name")
        };
    
        this.getValidatorData = this.getValidatorData.bind(this);
        this.renderHelpText = this.renderHelpText.bind(this);
        this.isValidated = this.isValidated.bind(this);
      }
    
      isValidated() {
        return new Promise((resolve, reject) => {
          this.props.validate((error) => {
            if (error) {
              reject(); // form contains errors
              console.log("Error fired");
              return;
            }
    
            if (this.props.getStore().packagename != this.getValidatorData().packagename) { // only update store of something changed
              this.props.updateStore({
                ...this.getValidatorData(),
                savedToCloud: true // use this to notify step4 that some changes took place and prompt the user to save again
              });  // Update store here (this is just an example, in reality you will do it via redux or flux)
             
              // Ajax send response to server goes here!
              console.log("Validation fired");
            
            }
    
            resolve(); // form is valid, fire action
            
          });
        });
      }
    
      getValidatorData() {
        return {
          packagename: this.refs.packagename.value,
        }
      };
    
      onChange(e) {
          let newState = {};
          newState[e.target.name] = e.target.value;
          this.setState(newState);
      }
    
      renderHelpText(message, id) {
        return (<div className="val-err-tooltip" key={id}><span>{message}</span></div>);
    };
    
    render() {
      // explicit class assigning based on validation
      let notValidClasses = {};
      notValidClasses.packagenameCls = this.props.isValid('packagename') ?
          'no-error col-md-8' : 'has-error col-md-8';
    
    return (
      
    
        <div className="step step1">
          <div className="row">
          
            <form id="Form" className="form-horizontal">
                <div id="stepscontainer" className="form-group">
                <label className="col-md-12 control-label">
                  <h2>Please provide a unique name for the package</h2>
                </label>
                <div className="row content">
                  <div className="col-md-12">
                      Give a short name that can identify the package with, using underscore and no spaces.
                      <br /><br />
                         <FormGroup row>
                         <Col xs="12" md="9">
                         <div className={notValidClasses.packagenameCls}>
                         <input
                                ref="packagename"
                                name="packagename"
                                autoComplete="off"
                                type="text"
                                className="form-control"
                                placeholder="Package name"
                                required
                                defaultValue={this.state.packagename}
                                id="packagename"
                                onBlur={this.props.handleValidation('packagename')}
                                onChange={this.onChange.bind(this)}
                                size="145" />
                            {this.props.getValidationMessages('packagename').map(this.renderHelpText)}
                         </div>
                        </Col>
                      </FormGroup>
                  
                  </div>
                  <div className="col-md-12 eg-jump-lnk">
                   
                  </div>
                </div>
              </div>
              
            </form>
          </div>
          </div>
        )
      }
    }
    
    Step1.propTypes = {
      errors: PropTypes.object,
      validate: PropTypes.func,
      isValid: PropTypes.func,
      handleValidation: PropTypes.func,
      getValidationMessages: PropTypes.func,
      clearValidations: PropTypes.func,
      getStore: PropTypes.func,
      updateStore: PropTypes.func
    };
    
    
    export default validation(strategy)(Step1);
    
    

    Thanks, Dan

    12 Dec
    11 months ago

    dk4210 left a reply on Jquery Question

    Dang my stupid mistake. It works now. I knew that. Thanks for your help!

    dk4210 left a reply on Jquery Question

    Opps I saw that and removed it, but still doesn't work.

    <div class="headertxt">Activity</div>
    <hr>
    <script>
      var aoptions = [
         { "href": "s2pstandpack.jsp", "text": "OPQ32R DeviceOpt Component" },
         { "href": "s2psolution.jsp", "text": "VATGUNR scaleset" },
         { "href": "tcstandpack.jsp", "text": "G+ Package" },
         { "href": "tcsolution.jsp", "text": "MoE Custom Report" },
         { "href": "tcsolution.jsp", "text": "VATNR Professional Normgroup" }
    ];
    
    $.each(aoptions, function(index) {
        $("activityList").append($('<li> <i class="fa fa-link" aria-hidden="true"></i>').append($(" <a>", { href: aoptions[index].href, text : aoptions[index].text})));
        console.log(aoptions[index].text);
    });
    
    </script>
          <ul id="activityList"></ul>