dcaldessa

Experience

2,340

0 Best Reply Awards

  • Member Since 1 Year Ago
  • 13 Lessons Completed
  • 0 Favorites

1st February, 2018

dcaldessa left a reply on {Question} Editing .env Dynamically • 7 months ago

Yeah I took a look at it, now to just figure how it want to implement it all .. thanks for the pointer to the post hope I can get everything sorted :)

dcaldessa left a reply on {Question} Editing .env Dynamically • 7 months ago

I need to alter the database name, user name, password of the database from a GUI that I am creating on the administrator side of my application. Still new to laravel I do not know all the little tricks to get stuff done like this :) .

dcaldessa started a new conversation {Question} Editing .env Dynamically • 7 months ago

I am working on an site that is going to be a sort of CMS and I was looking for a way to enter data into the .env from the backend of my site. I found a package that allows the editing of the .env dynamically the package is located here

https://github.com/Brotzka/laravel-dotenv-editor

What I wanted to know is if it was safe to use a package like this to get the results that I need? Or is it going to be a security breach of my application..

looking for some input on this so I can figure out the right direction to go .

14th January, 2018

dcaldessa left a reply on Issue With Closure Route • 8 months ago

no other route with that name

dcaldessa left a reply on Issue With Closure Route • 8 months ago

no this is the only route called userSelection, I can test for sure though by trying another name but pretty positive it is the only one .

13th January, 2018

dcaldessa started a new conversation Issue With Closure Route • 8 months ago

I have a route that I am trying to set to a simple page but it is not working this is what I have

Route::get('userSelection', function(){
    $roles = \dracanon\Role::all();
    return view('admin.users.note.iframe.noteUserSelectionModalContent');
});

and when i go to the url

http://dracanon.site/userSelection

I keep getting the following error


(1/1) ErrorException
Undefined index: controller

in ControllerActionNameComposer.php (line 16)
at HandleExceptions->handleError(8, 'Undefined index: controller', 'D:\Ampps\www\dracanon.dev\app\Http\Composers\ControllerActionNameComposer.php', 16, array('view' => object(View), 'action' => array('middleware' => 'web', 'uses' => object(Closure), 'namespace' => 'dracanon\Http\Controllers', 'prefix' => null, 'where' => array())))
in ControllerActionNameComposer.php (line 16)

Not sure why I am getting this error on a simple route, my friend has the same project that I am working with on his pc and his routes go through fine. Any help to solve this would be great I am at a loss where I sould be looking for a resolution.

6th January, 2018

dcaldessa left a reply on Need Help Passing Id From Modal To View • 8 months ago

@mleppala

Thanks for the indepth coverage of my issue, It really helped me understand more of what is going on..

I did implement the code and it worked perfectly keep up the good work.

5th January, 2018

dcaldessa started a new conversation Need Help Passing Id From Modal To View • 8 months ago

Greetings all,

I am in need of a little help I have a modal window that puts users in a table list. I can click on the user and pass the user first name and last name to a text box in my view so that part is working.

What I am having trouble with is passing the user Id from the modal to a hidden field in my view. I was wondering if some one could point me in the right direction on getting this done . .

my modal table looks like this

 <tbody>
                        @foreach( $users as $user)
                            <tr class="row0">
                                <td>
                                    <a href="#" class="pointer button-select" data-user-value="{{$user->id}}"
                                    data-user-name="{{$user->firstName}} {{$user->lastName}}" data-dismiss="modal">{{$user->firstName}} {{$user->lastName}}</a>
                                </td>
                                <td align="left">
                                    {{$user->login_name}}
                                </td>
                                <td align="left">
                                    {{--{{dd($user->roles->pluck('id','name'))}}--}}
                                    @foreach($user->roles->pluck('id','name') as $key =>$group)
                                        {{--{{dd($key)}}--}}
                                        <div data-id="{{$group}}">{{$key}}</div>

                                    @endforeach
                                </td>
                            </tr>
                        @endforeach
                    </tbody>
                </table>

and the view inputs are like this

 <div class="input-control label-left input-group">
                                <input type="text" name="user" id="user" class="form-control" placeholder="Select a User" readonly>
                                <input  type="hidden" name="user_id" id="user_id">
                                <span class="user-span input-group-btn">
                                    <span>
                                        <button class="button-user btn btn-default" type="button" data-toggle="modal" data-target="#notemodal">
                                            <i class=" fa fa-user"></i>
                                        </button>
                                    </span>
                                </span>
                            </div>

any help would be appreciated ..

9th December, 2017

dcaldessa started a new conversation Set Expire Time On Activation Email Key • 9 months ago

Hey all,

I have an email activation system set up the only thing i cannot quite figure out is how to set a time to expire for the activation key, i.e the user must activate their account within 30 min of receiving the activation email or they will have to request a new email with a new key ? Any pointers on this would be helpful.

thanks D

28th June, 2017

dcaldessa started a new conversation Phpstorm ,laravel And Xdebug • 1 year ago

I have searched everywhere and even watched the laracasts videos with xdebug, In the videos Jeffery way simply uses xdebug to debug his application. What is not shown is how to configure it to work. I was able to get it configured to start a debug session but every time I run it. I keep getting the laravel index.php boot. I can never get it to go to the break points in my controllers so I cannot properly debug them. Does anyone have any other suggestions on how I can set this up??

If I attempt to debug my controller by clicking run and selecting the controller I get this

D:\Ampps\php\php.exe D:\Ampps\www\dracanon.dev\app\Http\Controllers\Auth\LoginController.php
PHP Fatal error:  Class 'App\Http\Controllers\Controller' not found in D:\Ampps\www\dracanon.dev\app\Http\Controllers\Auth\LoginController.php on line 12
PHP Stack trace:
PHP   1. {main}() D:\Ampps\www\dracanon.dev\app\Http\Controllers\Auth\LoginController.php:0

Fatal error: Class 'App\Http\Controllers\Controller' not found in D:\Ampps\www\dracanon.dev\app\Http\Controllers\Auth\LoginController.php on line 12

Call Stack:
    0.0003     365864   1. {main}() D:\Ampps\www\dracanon.dev\app\Http\Controllers\Auth\LoginController.php:0


Process finished with exit code 255

It only does this with xdebug , the version of xdebug is 2.4.0

I have installed the barry/ide helper and generated the helper file but that does not seem to be working.

xdebug is set to go off the autoloader.php as well,

Is there any other suggestions or processes I can look at doing?

any help would be appreciated.

22nd June, 2017

dcaldessa started a new conversation Location Authentication • 1 year ago

Hello laracasts,

I am looking to implement a system like Steam's steam guard. Where you login to your account and It pops up with a modal asking for a unique code that was sent to the authenticated users email address that was provided during registration.

The following screenshots are examples of what I am looking to do .

The initial message upon login. http://s38.photobucket.com/user/dcaldessa/media/steamguard_zpsoysif1yk.jpg.html?sort=3&o=1

and the email that is sent with the code. http://i38.photobucket.com/albums/e119/dcaldessa/steamguardmessage_zpswtqnobjn.jpg

The user cannot finish the login process without this code.

It appears that the information is saved as a cookie on the system to be validated on every login. If the cookie is removed or ip has changed the user will be asked to input another code for their account to be accessible.

I do not know if there is a package for this and it is not truly a 2 factor authentication it is something in between.

any Ideas or points in the right direction on how I could get this implemented would be great.

thanks

21st June, 2017

dcaldessa left a reply on Possible To Have A Link In A Flash Message • 1 year ago

I copied and pasted the code you provided for the redirect and link

return redirect('login')
                    ->with('message',"Your account is not yet active. <a href='{ url('/activation/resend') }'>Click here</a> to resend the activation email.")
                    ->with('status', 'danger');

All it does is display as text there is no link to click on.

20th June, 2017

dcaldessa left a reply on Possible To Have A Link In A Flash Message • 1 year ago

I have figured out the issue, Two words....Unique usernames... there are two different users in my database with the same username. It was hitting on the first one that was active never making it to the second username.. so the code is correct .. my db is wrong... time for me to add a check for unique usernames in my validation and database....

thank you for your time on this @Snapey you have been diligent and friendly I look forward to our next conversation.

Loving laravel and laracasts !!

dcaldessa left a reply on Possible To Have A Link In A Flash Message • 1 year ago

This is my Login Controller in it's current state

<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use App\User;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class LoginController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Login Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles authenticating users for the application and
    | redirecting them to your home screen. The controller uses a trait
    | to conveniently provide its functionality to your applications.
    |
    */

    use AuthenticatesUsers;

    /**
     * Auth guard
     *
     * @var
     */
    protected $auth;
    /**
     * lockoutTime
     *
     * @var
     */
    protected $lockoutTime;

    /**
     * maxLoginAttempts
     *
     * @var
     */
    protected $maxLoginAttempts;
    /**
     * Where to redirect users after login.
     *
     * @var string
     */
    protected $redirectTo = '/';
    /**
     * Where to redirect user after logout
     *
     * @var string
     */
    protected $redirectAfterLogout = '/';
    /**
     * Create a new controller instance.
     *
     * @param Guard $auth
     */
    public function __construct(Guard $auth)
    {
        $this->middleware('guest', ['except' => 'logout']);
        $this->auth = $auth;
        $this->maxLoginAttempts = 5;//lockout after 5 attempts
        $this->lockoutTime = 1; //lockout for 1 minute (value is in minutes)

    }
    /**
     * Determine if the user has too many failed login attempts.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return bool
     */
    protected function hasTooManyLoginAttempts(Request $request)
    {
        return $this->limiter()->tooManyAttempts(
            $this->throttleKey($request), $this->maxLoginAttempts, $this->lockoutTime
        );
    }
    /**
     * Get the login username to be used by the controller.
     *
     * @return string
     */
    public function username()
    {
        return 'username';
    }
    /**
    * Validate the user login request.
    *
    * @param  \Illuminate\Http\Request  $request
    * @return void
    */
    protected function validateLogin(Request $request)
    {
        $this->validate($request, [
            $this->username() => 'required', 'password' => 'required',
        ]);
    }

    public function login(Request $request)
    {
        // Validate the login request
        $this->validateLogin($request);

        //Check if user  has surpassed their allowed login attempts
        //Keyed by the username and IP address of the client making
        //the request.
        if ($this->hasTooManyLoginAttempts($request)){
            $this->fireLockoutEvent($request);

            return $this->sendLockoutResponse($request);
        }

        // Attempt the login of the user.
        $username = $request->get('username');
        $password = $request->get('password');
        $remember = $request->get('remember');


        if ($this->auth->attempt([
            'username' => $username,
            'password'  => $password
        ], $remember == 1 ? true : false)) {

            // SUCCESS: now we check for the activation status to proceed or kick out the user
            if($this->guard()->user()->activated){
                // ACTIVATED: we redirect to the dashboard. but first, we clear the login attempts session
                $request->session()->regenerate();
                $this->clearLoginAttempts($request);

                return redirect()->action('Front\[email protected]');

            }else {
                // NOT ACTIVATED:  activated. redirect to login and kick them out
                $this->guard()->logout();
                $request->session()->flush();
                $request->session()->regenerate();

                return redirect('login')
                    ->with('message', 'You have not activated your account yet. Please activate your account first.')
                    ->with('status', 'danger');
            }
            
        } else {

                    // FAIL: If the login attempt was unsuccessful we will increment the number of attempts
                    // to login and redirect the user back to the login form. Of course, when this
                    // user surpasses their maximum number of attempts they will get locked out.
                    $this->incrementLoginAttempts($request);

                    return redirect()->back()
                        ->with('message', 'Incorrect username or password')
                        ->with('status', 'danger')
                        ->withInput();
                }

            }
    /**
     * Log the user out of the application.
     *
     * @param \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function logout(Request $request)
    {
        $this->guard()->logout();
        $request->session()->flush();
        $request->session()->regenerate();

        flash()->success('You have successfully logged out!');
        return redirect('/');

    }
}


dcaldessa left a reply on Possible To Have A Link In A Flash Message • 1 year ago

So i tried the user

  $username = $request->get('username');
        $password = $request->get('password');
        $remember = $request->get('remember');

        dd($this->guard()-user());

        if ($this->auth->attempt([
            'username'     => $username,
            'password'  => $password
        ], $remember == 1 ? true : false))

it does not hit it, just goes right to the invalid password condition

else {

            // FAIL: If the login attempt was unsuccessful we will increment the number of attempts
            // to login and redirect the user back to the login form. Of course, when this
            // user surpasses their maximum number of attempts they will get locked out.
            $this->incrementLoginAttempts($request);

            return redirect()->back()
                ->with('message','Incorrect username or password')
                ->with('status', 'danger')
                ->withInput();
        }

It's like it is not seeing the inside if statement at all...

if i dump it above the valid user statement we get

FatalThrowableError in LoginController.php line 124:
Call to undefined function App\Http\Controllers\Auth\user()

kinda loosing my mind here at the moment

dcaldessa left a reply on Possible To Have A Link In A Flash Message • 1 year ago

dd(if($this->guard()->user()->activated))

just above the initial if statement to see if it was getting any data, not sure if that was the correct way of doing it but either way I am still not getting the message.

dcaldessa left a reply on Possible To Have A Link In A Flash Message • 1 year ago

I did remove the 'activated' => 1 and tested again, it is completely ignoring the else statement for that block.. like it is not even seeing it. i did die dump the conditional , $this->guard()->user()->activated and got an error cannot get property of non object. Maybe somehow it is not getting the data . Perhaps there is a different way of writing this auth check maybe in it's own method.. not sure..

19th June, 2017

dcaldessa left a reply on Possible To Have A Link In A Flash Message • 1 year ago

So i added a check, to check if user is activated if it is login and route to user index , else show error message

here is my code

if($this->auth->attempt([
            'username' => $username,
            'password' => $password,
            'activated' => 1
        ],$remember == 1 ? true : false)) {
            if($this->guard()->user()->activated){

                //Success: clear the login attempts session and redirect
                //user to the user dashboard.
                $request->session()->regenerate();
                $this->clearLoginAttempts($request);

                return redirect()->action('Front\[email protected]');

            }else{

                //Not Activated redirect to login and kick them out
                $this->guard()->logout();
                $request->session()->flush();
                $request->session()->regenerate();

                return redirect('login')
                    ->with('message',"Your account is not yet active. <a href='{ url('/activation/resend') }'>Click here</a> to resend the activation email.")
                    ->with('status','danger')
                    ->withInput();
            }

        }
        else{
            //Fail: If login attempt was unsuccessful, increment the number of attempts
            //to login and redirect user back to login form, if user surpasses the maximum
            //number of attempts user will be locked out for a certain amount of time.
            $this->incrementLoginAttempts($request);
            
            return redirect()->back()
                ->with('message','Incorrect username or password!!!!')
                ->with('status','danger')
                ->withInput();
        }

but seems it is not hitting the check for the else cause it bypasses it to the invalid username/password error message.

dcaldessa left a reply on Possible To Have A Link In A Flash Message • 1 year ago

I tested everything and It seems it is not hitting the redirect at all.. I did some modification and I have this in my login view

@extends('layouts.app')

@section('styles')
    <link rel="stylesheet" href="{{asset('css/auth-registration.css')}}">
@stop

@section('content')
    <div class="container">
        <div class="row">
            <div class="col-md-8 col-md-offset-2 panel-container pcontainer">
                <div class="panel panel-default pdefault">
                    <div class="panel-heading">{{trans('front-end.DRAC_FRONT-END_LOGIN')}}</div>

                    <div class="panel-body pbody">
                        <div class="description header-description">
                            @include('notifications.status_message')
                            @include('notifications.errors_message')
                        </div>
                        <form class="bt-flabels js-flabels" method="POST" action="{{ url('/login') }}">
                            {{ csrf_field() }}

                            <div class="form-group">
                                <div class="bt-flabels__wrapper {{$errors->first('username') ? 'bt-flabels__error' : ''}}">
                                    <label>Username</label>
                                    <input type="text" name="username" placeholder="Username" autocomplete="off"
                                           data-parsley-required
                                           data-parsley-trigger="change focusout"
                                           data-parsley-minlength="3"
                                           data-parsley-maxlength="32"
                                            {{$errors->first('username') ? 'data-parsley-id="9" class="parsley-error"' : ''}}
                                    />
                                    <span class="bt-flabels__error-desc {{$errors->first('username') ? 'bt-flabels__error' : ''}}">Required</span>
                                </div>
                            </div>

                            <div class="form-group">
                                <div class="bt-flabels__wrapper {{$errors->first('password') ? 'bt-flabels__error' : ''}}">
                                    <label>Password</label>
                                    <input type="password" id="password" name="password" placeholder="Password"
                                           data-parsley-required
                                           autocomplete="off"
                                           data-parsley-required-message="A password is required"
                                           data-parsley-trigger="change focusout"
                                           data-parsley-minlength="8"
                                           data-parsley-maxlength="20"
                                            {{$errors->first('password') ? 'data-parsley-id="13" class="parsley-error"' : ''}}
                                    />
                                    <span class="bt-flabels__error-desc {{$errors->first('password') ? 'bt-flabels__error' : ''}}">{{trans('front-end.DRAC_FRONT-END_VALIDATION_EMAILREQUIRED')}}</span>
                                </div>
                            </div>


                            <div class="form-group btn-submit">
                                <button class="btn btn-lg btn-primary btn-block" type="submit">{{trans('front-end.DRAC_FRONT-END_LOGIN')}}</button>
                            </div>
                            <div class="link-container">
                                 <a href="{{ url('/username/reminder') }}" class="forgot-password">{{trans('front-end.DRAC_FRONT-END_FORGOTUN')}}</a> or
                                <a href="{{ url('/password/reset') }}" class="forgot-password">{{trans('front-end.DRAC_FRONT-END_FORGOTPW')}}</a>
                            </div>
                        </form><!-- /form -->
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection

@section('scripts')
    <script src="{{asset('js/plugins/parsley/parsley.min.js')}}"></script>
@stop

these are the notifications.status.message and notifications.errors_message.

@if(Session::has('message'))
    <div class="alert alert-{{ Session::get('status') }} status-box">
        <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
        {{ Session::get('message') }}
    </div>
@endif

@if(session()->has('errors'))
    <div class="alert alert-danger fade in">
        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
        <h4>Following errors occurred:</h4>
        <ul>
            @foreach($errors->all() as $error)
                <li>{{ $error }}</li>
            @endforeach
        </ul>
    </div>
@endif

I create a test user, then try to login expecting to get the message that the account is not activated. All I get is Invalid username or password, even though the information is correct. I verified by activating the account via the email that is sent out I then can log into the account with no issues. So somewhere my logic seems to be incorrect again I am just not seeing it.

dcaldessa left a reply on Possible To Have A Link In A Flash Message • 1 year ago

How can I use this code in my LoginController ? As that is where it all resides at the moment. I am also looking into maybe creating a event for the activation message. Im still learning so it is taking some time to come up with the a solution that is quick and manageable.

dcaldessa started a new conversation Possible To Have A Link In A Flash Message • 1 year ago

I am working on dealing with checking if a user is active or not before login.

this is my current login code

public function login(Request $request)
    {
        // Validate the login request
        $this->validateLogin($request);

        //Check if user  has surpassed their allowed login attempts
        //Keyed by the username and IP address of the client making
        //the request.
        if ($this->hasTooManyLoginAttempts($request)){
            $this->fireLockoutEvent($request);

            return $this->sendLockoutResponse($request);
        }

        // Attempt the login of the user.
        $username = $request->get('username');
        $password = $request->get('password');
        $remember = $request->get('remember');


        if($this->auth->attempt([
            'username' => $username,
            'password' => $password,
            'activated' => 1
        ],$remember == 1 ? true : false)) {

            if($this->guard()->user()->activated){
                //Success: clear the login attempts session and redirect
                //user to the user dashboard.
                $request->session()->regenerate();
                $this->clearLoginAttempts($request);

                return redirect()->action('Front\[email protected]');
            }else{
                //Not Activated redirect to login and kick them out
                $this->guard()->logout();
                $request->session()->flush();
                $request->session()->regenerate();

                return redirect('login')
                    ->with('activation_response', 'action.danger');
            }

        }
        else{
            //Fail: If login attempt was unsuccessful, increment the number of attempts
            //to login and redirect user back to login form, if user surpasses the maximum
            //number of attempts user will be locked out for a certain amount of time.
            $this->incrementLoginAttempts($request);
            
            return redirect()->back()
                ->with('message','Incorrect username or password')
                ->with('status','danger')
                ->withInput();
        }
    }

on the check if the user is not active , I want to display a flash message telling them the account is not active but i want to include a link to the resend activation page.

my attempt to do this is not working, is there a way that I can do this ?

I do have the package laracasts/flash installed as well.

looking for some direction on how to get this done .

thanks.

16th June, 2017

dcaldessa left a reply on Google ReCaptcha And Client-side/server-side Validation • 1 year ago

I have resolved the issue. ill post the changes made below that we used to fix the issue for those that may be interested in the solution.

in our view we made changes to how the inputs are validated. it now uses both client side and server side validation.

code below

@extends('layouts.app')

@section('styles')
    <link rel="stylesheet" href="{{asset('css/auth-registration.css')}}">
@stop

@section('content')
    <div class="container">
        <div class="row">
            <div class="col-md-8 col-md-offset-2">
                <div class="panel panel-default">
                    <div class="panel-heading">Register</div>
                    <div class="panel-body">
                        <div class="bt-form__wrapper">
                            <form class="form-horizontal bt-flabels js-flabels" id="form-register" role="form" method="POST" action="{{ url('/register') }}" data-parsley-errors-messages-disabled="true">
                                {{ csrf_field() }}

                                <div class="form-group">
                                    <div class="bt-flabels__wrapper {{$errors->first('firstName') ? 'bt-flabels__error' : ''}}">
                                        <label for="firstName">First Name</label>
                                        <input type="text" id="field" name="firstName" placeholder="First Name" autocomplete="off"
                                               data-parsley-required
                                               data-parsley-trigger="change focusout"
                                               data-parsley-pattern="/^[a-zA-Z]*$/"
                                               data-parsley-minlength="3"
                                               data-parsley-maxlength="32"
                                                {{$errors->first('firstName') ? 'data-parsley-id="5" class="parsley-error"' : ''}}
                                        />
                                        <span class="bt-flabels__error-desc {{$errors->first('firstName') ? 'bt-flabels__error' : ''}}">Required</span>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <div class="bt-flabels__wrapper {{$errors->first('lastName') ? 'bt-flabels__error' : ''}}">
                                        <label>Last Name</label>
                                        <input type="text" name="lastName" placeholder="Last Name" autocomplete="off"
                                               data-parsley-required
                                               data-parsley-trigger="change focusout"
                                               data-parsley-pattern="/^[a-zA-Z]*$/"
                                               data-parsley-minlength="3"
                                               data-parsley-maxlength="32"
                                                {{$errors->first('lastName') ? 'data-parsley-id="7" class="parsley-error"' : ''}}
                                        />
                                        <span class="bt-flabels__error-desc {{$errors->first('lastName') ? 'bt-flabels__error' : ''}}">Required</span>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <div class="bt-flabels__wrapper {{$errors->first('username') ? 'bt-flabels__error' : ''}}">
                                        <label>Username</label>
                                        <input type="text" name="username" placeholder="Username" autocomplete="off"
                                               data-parsley-required
                                               data-parsley-trigger="change focusout"
                                               data-parsley-minlength="3"
                                               data-parsley-maxlength="32"
                                                {{$errors->first('username') ? 'data-parsley-id="9" class="parsley-error"' : ''}}
                                        />
                                        <span class="bt-flabels__error-desc {{$errors->first('username') ? 'bt-flabels__error' : ''}}">Required</span>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <div class="bt-flabels__wrapper {{$errors->first('email') ? 'bt-flabels__error' : ''}}">
                                        <label>Email</label>
                                        <input type="email" name="email" placeholder="Email"
                                               data-parsley-required
                                               data-parsley-required-message="Email is required"
                                               data-parsley-trigger="change focusout"
                                               data-parsley-type="email"
                                               autocomplete="off"
                                               {{$errors->first('email') ? 'data-parsley-id="11" class="parsley-error"' : ''}}
                                        />
                                        <span class="bt-flabels__error-desc {{$errors->first('email') ? 'bt-flabels__error' : ''}}">Required/Invalid Email</span>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <div class="bt-flabels__wrapper {{$errors->first('password') ? 'bt-flabels__error' : ''}}">
                                        <label>Password</label>
                                        <input type="password" id="password" name="password" placeholder="password"
                                               data-parsley-required
                                               autocomplete="off"
                                               data-parsley-required-message="A password is required"
                                               data-parsley-trigger="change focusout"
                                               data-parsley-minlength="8"
                                               data-parsley-maxlength="20"
                                               {{$errors->first('password') ? 'data-parsley-id="13" class="parsley-error"' : ''}}
                                        />
                                        <span class="bt-flabels__error-desc {{$errors->first('password') ? 'bt-flabels__error' : ''}}">Required/Invalid</span>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <div class="bt-flabels__wrapper {{$errors->first('password_confirmation') ? 'bt-flabels__error' : ''}}">
                                        <label>Confirm Password</label>
                                        <input type="password" name="password_confirmation" placeholder="confirm password"
                                               data-parsley-required
                                               autocomplete="off"
                                               data-parsley-trigger="change focusout"
                                               data-parsley-minlength="8"
                                               data-parsley-maxlength="20"
                                               data-parsley-equalto="#password"
                                                {{$errors->first('password_confirmation') ? 'data-parsley-id="15" class="parsley-error"' : ''}}
                                        />
                                        <span class="bt-flabels__error-desc {{$errors->first('password_confirmation') ? 'bt-flabels__error' : ''}}">Required/Invalid/Mismatch</span>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <div class="col-md-6 col-md-offset-4">
                                        <button id="btnSubmit" class="btn btn-primary" type="submit">Register</button>
                                        @captcha()
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection

@section('scripts')
    <script src="{{asset('js/plugins/parsley/parsley.min.js')}}"></script>
@stop

dcaldessa started a new conversation Google ReCaptcha And Client-side/server-side Validation • 1 year ago

I am working on my registration page, I am at the point of adding validation. Now I am using parsley.js for the client side validation and I have the server side validation setup as well. I have also implemnted the invisible reCaptcha using this package

albertcht/invisible-recaptcha

https://github.com/albertcht/invisible-recaptcha

I have the reCaptcha implemented ok, but with it turned on in my view my client-side and server-side validation does not kick in .. It is like the reCaptcha triggers before my validation scripts..

I am seeking assistance in figuring out how I can get my client-side/server-side validation to be performed before the google reCaptcha

my registration view looks like this

@extends('layouts.app')

@section('styles')
    <link rel="stylesheet" href="{{asset('css/auth-registration.css')}}">
@stop
@section('content')
    <div class="container">
        <div class="row">
            <div class="col-md-8 col-md-offset-2">
                <div class="panel panel-default">
                    <div class="panel-heading">Register</div>
                    <div class="panel-body">
                        <div class="bt-form__wrapper">
                            <form class="uk-form bt-flabels js-flabels" id="registration" data-parsley-validate data-parsley-errors-messages-disabled>

                                <div class="form-group{{ $errors->has('lastName') ? ' has-error' : '' }}">
                                    <div class="bt-flabels__wrapper">
                                        <label>First Name</label>
                                        <input type="text" id="field" name="firstName" placeholder=" First Name" autocomplete="off"
                                               data-parsley-required
                                               data-parsley-trigger="change focusout"
                                               data-parsley-pattern="/^[a-zA-Z]*$/"
                                               data-parsley-minlength="3"
                                               data-parsley-maxlength="32"
                                        />
                                        <span class="bt-flabels__error-desc">Required</span>
                                        @if ($errors->has('lastName'))
                                            <span class="help-block">
                                                <strong>{{ $errors->first('lastName') }}</strong>
                                            </span>
                                        @endif
                                    </div>
                                </div>

                                <div class="form-group{{ $errors->has('lastName') ? ' has-error' : '' }}">
                                    <div class="bt-flabels__wrapper">
                                        <label>Last Name</label>
                                        <input type="text" name="lastName" placeholder=" Last Name" autocomplete="off"
                                               data-parsley-required
                                               data-parsley-trigger="change focusout"
                                               data-parsley-pattern="/^[a-zA-Z]*$/"
                                               data-parsley-minlength="3"
                                               data-parsley-maxlength="32"
                                        />
                                        <span class="bt-flabels__error-desc">Required</span>
                                        @if ($errors->has('lastName'))
                                            <span class="help-block">
                                                <strong>{{ $errors->first('lastName') }}</strong>
                                            </span>
                                        @endif
                                    </div>
                                </div>

                                <div class="form-group{{ $errors->has('username') ? ' has-error' : '' }}">
                                    <div class="bt-flabels__wrapper">
                                        <label>Username</label>
                                        <input type="text" name="username" placeholder=" Username" autocomplete="off"
                                               data-parsley-required
                                               data-parsley-trigger="change focusout"
                                               data-parsley-minlength="3"
                                               data-parsley-maxlength="32"
                                        />
                                        <span class="bt-flabels__error-desc">Required</span>

                                        @if ($errors->has('username'))
                                            <span class="help-block">
                                                <strong>{{ $errors->first('username') }}</strong>
                                            </span>
                                        @endif
                                    </div>
                                </div>

                                <div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
                                    <div class="bt-flabels__wrapper">
                                        <label>Email</label>
                                        <input type="email" name="email" placeholder=" Email"
                                               data-parsley-required
                                               data-parsley-required-message="Email is required"
                                               data-parsley-trigger="change focusout"
                                               data-parsley-type="email"
                                               autocomplete="off" />
                                        <span class="bt-flabels__error-desc">Required/Invalid Email</span>

                                        @if ($errors->has('email'))
                                            <span class="help-block">
                                                <strong>{{ $errors->first('email') }}</strong>
                                            </span>
                                        @endif
                                    </div>
                                </div>

                                <div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
                                    <div class="bt-flabels__wrapper">
                                        <label>Password</label>
                                        <input type="password" id="password" name="password" placeholder=" password"
                                               data-parsley-required
                                               autocomplete="off"
                                               data-parsley-required-message="A password is required"
                                               data-parsley-trigger="change focusout"
                                               data-parsley-minlength="8"
                                               data-parsley-maxlength="20"
                                        />
                                        <span class="bt-flabels__error-desc">Required</span>
                                        @if ($errors->has('password'))
                                            <span class="help-block">
                                                <strong>{{ $errors->first('password') }}</strong>
                                            </span>
                                        @endif
                                    </div>
                                 </div>

                                <div class="form-group">
                                    <div class="bt-flabels__wrapper">
                                        <label>Confirm Password</label>
                                        <input type="password" name="confirmpassword" placeholder=" confirm password"
                                               data-parsley-required
                                               autocomplete="off"
                                               data-parsley-trigger="change focusout"
                                               data-parsley-minlength="8"
                                               data-parsley-maxlength="20"
                                               data-parsley-equalto="#password"
                                        />
                                        <span class="bt-flabels__error-desc">Required</span>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <div class="col-md-6 col-md-offset-4">
                                        <button id="btnSubmit" class="btn btn-primary" type="submit">Register</button>
                                        @captcha()
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection

@section('scripts')
    <script src="{{asset('js/plugins/parsley/parsley.min.js')}}"></script>
@stop

The script for my client-side validation

$(document).ready(function() {
   
    (function($) {
        'use strict';

        var floatingLabel;

        floatingLabel = function(onload) {
            var $input;
            $input = $(this);
            if (onload) {
                $.each($('.bt-flabels__wrapper input'), function(index, value) {
                    var $current_input;
                    $current_input = $(value);
                    if ($current_input.val()) {
                        $current_input.closest('.bt-flabels__wrapper').addClass('bt-flabel__float');
                    }
                });
            }

            setTimeout((function() {
                if ($input.val()) {
                    $input.closest('.bt-flabels__wrapper').addClass('bt-flabel__float');
                } else {
                    $input.closest('.bt-flabels__wrapper').removeClass('bt-flabel__float');
                }
            }), 1);
        };

        $('.bt-flabels__wrapper input').keydown(floatingLabel);
        $('.bt-flabels__wrapper input').change(floatingLabel);

        window.addEventListener('load', floatingLabel(true), false);
        $('.js-flabels').parsley().on('form:error', function() {
            $.each(this.fields, function(key, field) {
                if (field.validationResult !== true) {
                    field.$element.closest('.bt-flabels__wrapper').addClass('bt-flabels__error');
                }
            });
        });

        $('.js-flabels').parsley().on('field:validated', function() {
            if (this.validationResult === true) {
                this.$element.closest('.bt-flabels__wrapper').removeClass('bt-flabels__error');
            } else {
                this.$element.closest('.bt-flabels__wrapper').addClass('bt-flabels__error');
            }
        });

    })(jQuery);
});

wondering if anyone can assist me in figuring out this issue thanks !

14th June, 2017

dcaldessa left a reply on Route Not Defined When The Route Is Defined • 1 year ago

changed this

Route::resource('/admin/users/roles/', 'AdminRolesController');

to

Route::resource('/admin/users/roles', 'AdminRolesController');

and it all works now ..

thanks for the suggestion I guess i was overlooking things to hard. :)

dcaldessa started a new conversation Route Not Defined When The Route Is Defined • 1 year ago

Hello,

I created a new route

Route::resource('/admin/users/roles/', 'AdminRolesController');

then defined a view in the AdminRolesController index method

public function index()
    {
        return view('admin.users.roles.index');
    }

then i defined the route in my admin template but i get

Route [groups.index] not defined. (View: D:\Ampps\www\dracanon.dev\resources\views\layouts\admin.blade.php) (View: D:\Ampps\www\dracanon.dev\resources\views\layouts\admin.blade.php)

when I run artisan route:list it shows this for the Roles route

 GET|HEAD|admin/users/roles|index|App\Http\Controllers\[email protected]                           | web          |
|        | POST      | admin/users/roles                                        | store                         | App\Http\Controllers\[email protected]                           | web          |
|        | GET|HEAD  | admin/users/roles/create                                 | create                        | App\Http\Controllers\[email protected]                          | web          |
|        | GET|HEAD  | admin/users/roles/{}                                   | show                          | App\Http\Controllers\[email protected]                            | web          |
|        | PUT|PATCH | admin/users/roles/{}                                     | update                        | App\Http\Controllers\[email protected]                          | web          |
|        | DELETE    | admin/users/roles/{}                                     | destroy                       | App\Http\Controllers\[email protected]                         | web          |
|        | GET|HEAD  | admin/users/roles/{}/edit                                | edit 

I do not understand why it is not properly generating the routes for the controller....

any help would be greatly appreciated.

2nd June, 2017

dcaldessa left a reply on Trying To Create Seeder For Belongstomany Pivot Table • 1 year ago

@EventFellows Well i'll be dammned, i knew it would be a simple solution guess i was over thinking it all ..

Thank you for your help !!

I look forward to posting my next problem you all are awesome. !

dcaldessa left a reply on Trying To Create Seeder For Belongstomany Pivot Table • 1 year ago

@EventFellows I tried the provided solution and get the following error

[Symfony\Component\Debug\Exception\FatalThrowableError]                                                              
  Type error: Argument 1 passed to Illuminate\Database\Eloquent\Relations\BelongsToMany::formatRecordsList() must be   
  of the type array, integer given, called in D:\Ampps\www\dracanon.dev\vendor\laravel\framework\src\Illuminate\Datab  
  ase\Eloquent\Relations\BelongsToMany.php on line 899 

dcaldessa left a reply on Trying To Create Seeder For Belongstomany Pivot Table • 1 year ago

@TerrePorter I tried the above solution and I get and error during the migration

[ErrorException]                                                  
  Undefined property: Illuminate\Database\Eloquent\Collection::$id  

dcaldessa left a reply on Trying To Create Seeder For Belongstomany Pivot Table • 1 year ago

If i loop through the Users::all() like this

$user = User::all();

        foreach ($user as $users){

            $users->userNote()->sync(Usernote::all());
        }

I get results for all my users 11 times each instead of one user and one note each . its a huge bit of data and not the desired result .. unless there is another way of doing it . ??

1st June, 2017

dcaldessa started a new conversation Trying To Create Seeder For Belongstomany Pivot Table • 1 year ago

Hello all

I am having an issue creating a seeder for my pivot table I did look through a few posts and tried from this post .

https://laracasts.com/discuss/channels/laravel/pivot-table-seeding

When i run the solution from the above post i get this result

   usernote_id user_id
1         1            1
2        2             1
3        3             1
4        4             1
5        5             1
6        6             1
7        7             1
8        8             1
9        9             1
10       10             1
11        11               1


It is filling in all the users but only the 1st note for usernote.

Im not sure what I can do at this point and am looking for some help.

this is what I have so far ..

my User model

  public function userNote(){

        return $this->belongsToMany('App\Usernote');
    }

and my Usernote model

public function user(){

        return $this->belongsToMany('App\User');
    }

and my pivot table migration .

 Schema::create('user_usernote',function (Blueprint $table){
            $table->integer('usernote_id')->unsigned();
            $table->integer('user_id')->unsigned();
        });
Artisan::call('db:seed',[
            '--class' => UsersNotesAndPivot::class,
        ]);

and my Seeder file

<?php

use App\User;
use App\Usernote;
use Illuminate\Database\Seeder;

class UsersNotesAndPivot extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $this->createUsers();
        $this->createUserNotes();

        $users = User::first();
        $users->userNote()->sync(Usernote::all());
        



    }

    protected function createUsers(){

        User::create([
            'groupid' => ["6","1"],
            'firstName' => 'Don',
            'lastName' => 'Somers',
            'login_name' => 'dsomers',
            'password' => Hash::make('password'),
            'email' => '[email protected]',
            'backEndLanguage' => 'English',
            'frontEndLanguage' => 'English',
            'timezone' => 'America/Detroit'
        ]);
        User::create([
            'groupid' => ["6","2","7","8","9"],
            'firstName' => 'Dan',
            'lastName' => 'Wilkins',
            'login_name' => 'dwilkins',
            'password' => Hash::make('password'),
            'email' => '[email protected]',
            'backEndLanguage' => 'English',
            'frontEndLanguage' => 'English',
            'timezone' => 'America/Detroit'
        ]);
        User::create([
            'groupid' => ["6","3"],
            'firstName' => 'Jamie',
            'lastName' => 'Saparo',
            'login_name' => 'jsaparo',
            'password' => Hash::make('password'),
            'email' => '[email protected]',
            'backEndLanguage' => 'English',
            'frontEndLanguage' => 'English',
            'timezone' => 'America/Detroit'
        ]);
        User::create([
            'groupid' => ["6","4","10","9","8"],
            'firstName' => 'Elsa',
            'lastName' => 'Tomkins',
            'login_name' => 'eTomkins',
            'password' => Hash::make('password'),
            'email' => '[email protected]',
            'backEndLanguage' => 'English',
            'frontEndLanguage' => 'English',
            'timezone' => 'America/Detroit'
        ]);
        User::create([
            'groupid' => ["6","5","10"],
            'firstName' => 'Pete',
            'lastName' => 'Shadi',
            'login_name' => 'pshadi',
            'password' => Hash::make('password'),
            'email' => '[email protected]',
            'backEndLanguage' => 'English',
            'frontEndLanguage' => 'English',
            'timezone' => 'America/Detroit'
        ]);
        User::create([
            'groupid' => ["6","11"],
            'firstName' => 'Kris',
            'lastName' => 'Coro',
            'login_name' => 'kcoro',
            'password' => Hash::make('password'),
            'email' => '[email protected]',
            'backEndLanguage' => 'English',
            'frontEndLanguage' => 'English',
            'timezone' => 'America/Detroit'
        ]);
        User::create([
            'groupid' => ["6","7","8","9"],
            'firstName' => 'Leslie',
            'lastName' => 'Shipero',
            'login_name' => 'lshipero',
            'password' => Hash::make('password'),
            'email' => '[email protected]',
            'backEndLanguage' => 'English',
            'frontEndLanguage' => 'English',
            'timezone' => 'America/Detroit'
        ]);
        User::create([
            'groupid' => ["6","8","9","10"],
            'firstName' => 'Kristen',
            'lastName' => 'Renee',
            'login_name' => 'krenee',
            'password' => Hash::make('password'),
            'email' => '[email protected]',
            'backEndLanguage' => 'English',
            'frontEndLanguage' => 'English',
            'timezone' => 'America/Detroit'
        ]);
        User::create([
            'groupid' => ["6","9","4","7"],
            'firstName' => 'Loylld',
            'lastName' => 'Christof',
            'login_name' => 'lchristof',
            'password' => Hash::make('password'),
            'email' => '[email protected]',
            'backEndLanguage' => 'English',
            'frontEndLanguage' => 'English',
            'timezone' => 'America/Detroit'
        ]);
        User::create([
            'groupid' => ["6","10"],
            'firstName' => 'Mary',
            'lastName' => 'Fenhouser',
            'login_name' => 'mfenhouser',
            'password' => Hash::make('password'),
            'email' => '[email protected]',
            'backEndLanguage' => 'English',
            'frontEndLanguage' => 'English',
            'timezone' => 'America/Detroit'
        ]);
        User::create([
            'groupid' => ["6","11","5","7","8","9","10"],
            'firstName' => 'Timothy',
            'lastName' => 'McKernen',
            'login_name' => 'mckernent',
            'password' => Hash::make('password'),
            'email' => '[email protected]',
            'backEndLanguage' => 'English',
            'frontEndLanguage' => 'English',
            'timezone' => 'America/Detroit'
        ]);
    }

    protected function createUserNotes(){

        Usernote::create([
            'subject' => 'Don Somers',
            'category' => 'Uncategorised',
            'status' => 'Unpublished',
            'reviewDate' => '2017-06-01',
            'versionNote' => '1.0',
            'note' => 'This is some test data'
        ]);
        Usernote::create([
            'subject' => 'Dan Wilkins',
            'category' => 'Uncategorised',
            'status' => 'Unpublished',
            'reviewDate' => '2017-06-01',
            'versionNote' => '1.0',
            'note' => 'This is some test data'
        ]);
        Usernote::create([
            'subject' => 'Jamie Saparo',
            'category' => 'Uncategorised',
            'status' => 'Unpublished',
            'reviewDate' => '2017-06-01',
            'versionNote' => '1.0',
            'note' => 'This is some test data'
        ]);
        Usernote::create([
            'subject' => 'Elsa Tomkins',
            'category' => 'Uncategorised',
            'status' => 'Unpublished',
            'reviewDate' => '2017-06-01',
            'versionNote' => '1.0',
            'note' => 'This is some test data'
        ]);
        Usernote::create([
            'subject' => 'Pete Shadi',
            'category' => 'Uncategorised',
            'status' => 'Unpublished',
            'reviewDate' => '2017-06-01',
            'versionNote' => '1.0',
            'note' => 'This is some test data'
        ]);
        Usernote::create([
            'subject' => 'Kris Coro',
            'category' => 'Uncategorised',
            'status' => 'Unpublished',
            'reviewDate' => '2017-06-01',
            'versionNote' => '1.0',
            'note' => 'This is some test data'
        ]);
        Usernote::create([
            'subject' => 'Leslie Shipero',
            'category' => 'Uncategorised',
            'status' => 'Unpublished',
            'reviewDate' => '2017-06-01',
            'versionNote' => '1.0',
            'note' => 'This is some test data'
        ]);
        Usernote::create([
            'subject' => 'Kristin Renee',
            'category' => 'Uncategorised',
            'status' => 'Unpublished',
            'reviewDate' => '2017-06-01',
            'versionNote' => '1.0',
            'note' => 'This is some test data'
        ]);
        Usernote::create([
            'subject' => 'Loylld Cristof',
            'category' => 'Uncategorised',
            'status' => 'Unpublished',
            'reviewDate' => '2017-06-01',
            'versionNote' => '1.0',
            'note' => 'This is some test data'
        ]);
        Usernote::create([
            'subject' => 'Mary Fenhouser',
            'category' => 'Uncategorised',
            'status' => 'Unpublished',
            'reviewDate' => '2017-06-01',
            'versionNote' => '1.0',
            'note' => 'This is some test data'
        ]);
        Usernote::create([
            'subject' => 'Timothy McKernen',
            'category' => 'Uncategorised',
            'status' => 'Unpublished',
            'reviewDate' => '2017-06-01',
            'versionNote' => '1.0',
            'note' => 'This is some test data'
        ]);
    }
}

any assistance would be great

thanks.

31st May, 2017

dcaldessa started a new conversation Create New Service Provider For View Composer Not Working.. • 1 year ago

Hello again

I am working with View composers I have read a few tutorials and get the basic idea at the moment I have my view composer in AppServiceProvder.php and it is working. I wanted to create my own Service Provider so i used the

artisan make:provider ViewComposerServiceProvider

it creates it no problem there I then register it in the config/app.php under providers.

when i add my code for the view composer in the boot method I refresh my page and get variable not found error.

I have looked all around for some answers to why my new service provider is not working.

checked my composer.json for

"psr-4": {
            "App\\": "app/"
        }

which is there, I have done composer dumpautoload , and artisan cache:clear

I even deleted the service provider and remade it by hand and it still is not being recognized by laravel as a new service provider

Just wondering if there is anything else that I am missing on this problem ?

for now ill go back to the AppServiceProvder.php but I really would like to organize the view composer in it's own Provider file..

any help is appreciated

dcaldessa started a new conversation Pass User From Href Click In A Modal Window To Textbox On Page. • 1 year ago

Hello,

Still new to laravel and currently working on a problem.

I have a modal window (userNote.blade.php) that has a table of users populated from database.

code for hyperlink

<a href="#" class="pointer button-select" data-user-value="{{$user->id}}"
                                    data-user-name="{{$user->firstName}} {{$user->lastName}}">{{$user->firstName}} {{$user->lastName}}</a>

this is working as intended it gets the firstname and last name and id of the user.

What I want to do is when the hypelink is clicked I want to pass the user id and username to a textbox located in create.blade.php it is part of a form that will be posted to the database.

code for textbox on create.blade.php

<input type="text" name="user" id="user" class="form-control" value="{{old('user')}}" placeholder="Select a User" disabled>

I know I will have to use jquery for this Im just not sure how i would go about this using laravel.

any help would be greatly appreciated.

24th May, 2017

dcaldessa left a reply on Unable To Get Route::resource Working With New Route. • 1 year ago

Gah .. thanks for catching that. Seems i have to update my blade template in phpstorm..

thanks for your assistance

dcaldessa left a reply on Unable To Get Route::resource Working With New Route. • 1 year ago

I did the the commands and cleared out everything still cannot get the create page with the "name"

if i do return 'message'

I get the message just fine ... it seems to be having an issue with the admin.user.notes.create string.

dcaldessa left a reply on Unable To Get Route::resource Working With New Route. • 1 year ago

I tried the suggested solution.

I moved the route for notes above the admin/user route and I was able to get the index page. I then tested to see if i could get my create page and it did not work still getting

InvalidArgumentException in FileViewFinder.php line 137:
View [admin.user.note.create] not found.

the method in my AdminUserNoteController is as follows

/**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        return view('admin.user.note.create');
    }

and in the route:list the name is "note.create", if i change it to just note.create I still get the exception saying that it cannot be found.

any other Ideas that I can try ??

dcaldessa started a new conversation Unable To Get Route::resource Working With New Route. • 1 year ago

I am having some issues with my new route. I am using Laravel 5.3.31, and have looked at the documentation for views and routes as far as i know im doing everything correctly.

This is how I have my folder structure for my views as follows

Views->
admin->(root folder)
      user->(sub-folder)
             create.blade.php( to create a user)-> route is working can get page
             edit.blade.php (to edit a user)-> route is working can get page
         index.blade.php(the index of users)-> route is working can get page
         Note->(sub-folder inside user folder)
                create.blade.php (to create a new note)
        edit.blade.php(to edit a new note)
        index.blade.php( index of user notes) 

My web.php routes are as follows

Route::resource('admin/user','AdminUserController'); -> this is working as expected

Route::resource('admin/user/note','AdminUserNoteController'); -> This is returning errors: InvalidArgumentException in FileViewFinder.php line 137:
View [admin.user.note.create] not found.


AdminUserNoteController looks like this

class AdminUserNoteController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        return view('admin.user.note.index');
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        return view('admin.user.note.create');
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }
}

and artisan route:list shows the following

|        | GET|HEAD  | admin/user                                    | user.index             | App\Http\Controllers\[email protected]             | web                                |
|        | POST      | admin/user                                    | user.store             | App\Http\Controllers\[email protected]             | web                                |
|        | GET|HEAD  | admin/user/create                             | user.create            | App\Http\Controllers\[email protected]            | web                                |
|        | POST      | admin/user/note                               | note.store             | App\Http\Controllers\[email protected]         | web                                |
|        | GET|HEAD  | admin/user/note                               | note.index             | App\Http\Controllers\[email protected]         | web                                |
|        | GET|HEAD  | admin/user/note/create                        | note.create            | App\Http\Controllers\[email protected]        | web                                |
|        | PUT|PATCH | admin/user/note/{note}                        | note.update            | App\Http\Controllers\[email protected]        | web                                |
|        | GET|HEAD  | admin/user/note/{note}                        | note.show              | App\Http\Controllers\[email protected]          | web                                |
|        | DELETE    | admin/user/note/{note}                        | note.destroy           | App\Http\Controllers\[email protected]       | web                                |
|        | GET|HEAD  | admin/user/note/{note}/edit                   | note.edit              | App\Http\Controllers\[email protected]          | web                                |
|        | POST      | admin/user/notecategories                     | notecategories.store   | App\Http\Controllers\[email protected]   | web                                |
|        | GET|HEAD  | admin/user/notecategories                     | notecategories.index   | App\Http\Controllers\[email protected]   | web                                |
|        | GET|HEAD  | admin/user/notecategories/create              | notecategories.create  | App\Http\Controllers\[email protected]  | web                                |
|        | DELETE    | admin/user/notecategories/{notecategory}      | notecategories.destroy | App\Http\Controllers\[email protected] | web                                |
|        | PUT|PATCH | admin/user/notecategories/{notecategory}      | notecategories.update  | App\Http\Controllers\[email protected]  | web                                |
|        | GET|HEAD  | admin/user/notecategories/{notecategory}      | notecategories.show    | App\Http\Controllers\[email protected]    | web                                |
|        | GET|HEAD  | admin/user/notecategories/{notecategory}/edit | notecategories.edit    | App\Http\Controllers\[email protected]    | web                                |
|        | GET|HEAD  | admin/user/{user}                             | user.show              | App\Http\Controllers\[email protected]              | web                                |
|        | PUT|PATCH | admin/user/{user}                             | user.update            | App\Http\Controllers\[email protected]            | web                                |
|        | DELETE    | admin/user/{user}                             | user.destroy           | App\Http\Controllers\[email protected]           | web                                |
|        | GET|HEAD  | admin/user/{user}/edit                        | user.edit              | App\Http\Controllers\[email protected] 

I do not understand why it is not working ?

Is there something about sub-folders within an existing sub-folder that I am not seeing in the documentation ?

23rd May, 2017

dcaldessa started a new conversation Language Switcher Persist On Edit Page • 1 year ago

I am using the mcamara/laravel-localization package in my project I have it working.

I have added a language switcher to my Create page and have it saving the chosen option to the database.

The issue I am having now is retrieving the saved option from the database and populating it in my edit page.

this is what I currently have as my code

<div class="label-container">
                                    <label for="front-end-language" class="control-label label-left">{{trans('admin.DRAC_ADMIN_FRONTEND_LANGUAGE')}}</label>
                                </div>
                                <div class="input-control label-left">
                                    <select class="form-control" name="frontEndLanguage" id="backend-language">
                                        @foreach(LaravelLocalization::getSupportedLocales() as $localeCode => $properties)
                                            <option value="{{$properties['regional']}}"
                                                    {{LaravelLocalization::getLocalizedURL($localeCode,null,[],true)}}
                                                    {{$properties['native'] == $user->frontEndLanguage ? 'selected' : ''}}>
                                                {{$properties['native']}}
                                            </option>
                                        @endforeach
                                    </select>
                                </div>


but this is not using the option saved in the database. Is there any other way of pulling the data for this option ?

any help would be greatly appreciated .

thanks

dcaldessa.

10th May, 2017

dcaldessa left a reply on Validation On Update With Unique ID • 1 year ago

I ran some more tests to see if I could narrow things down. What I have found is that after successful save of creating the user it takes me to the edit page which pulls all the user info from the database.

looks like we figured things out the return for our store method was changed from

return view('admin.user.edit',compact('user','groups'));

with this code

return \redirect('admin/user/'.$id.'/edit')->with('user', $user)->with('groups',$groups);

This gets us the expected result of creating a user. redirecting to the edit page. introduce validation error by removing the email we hit save and now get the expected result of the error popping up telling us we need an email address..

it looks crude to me but it works. If there is another way of writing it please feel free to let me know ..

I thank you for all your help during this ..

7th May, 2017

dcaldessa left a reply on Validation On Update With Unique ID • 1 year ago

@Nash

This is my AdminUserController


<?php

namespace App\Http\Controllers;

use App\Http\Requests\UserValidationStore;
use App\Http\Requests\UserValidationUpdate;
use App\User;
use App\UserGroup;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Session;
use Illuminate\Validation\Rule;

class AdminUserController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        return view('admin.user.index');
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        $groups = UserGroup::all();

        return view('admin.user.create',compact('groups'));
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(UserValidationStore $request)
    {

        $user = User::create($request->all());

        Session::flash('success', 'User successfully saved.');

        $groups = UserGroup::all();

        if ($request->get('submit') == 'saveAndClose'){
            return view('admin.user.index');
        }elseif ($request->get('submit') == 'saveAndNew'){
            return view('admin.user.create',compact('user','groups'));
        }
        return view('admin.user.edit',compact('user','groups'));
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {

    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        $user= User::findOrfail($id);
        $groups = UserGroup::all();

        return view('admin.user.edit',compact('user','groups'));
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(UserValidationUpdate $request, $id)
    {

        $user = User::findorfail($id);

        if(empty($request->password)){
            $user->update($request->except('password'));
        }
        else{
            $user->update($request->all());
        }

        Session::flash('success', 'User successfully saved.');

        $groups = UserGroup::all();

        if ($request->get('submit') == 'saveAndClose'){
            return view('admin.user.index');
        }elseif ($request->get('submit') == 'saveAndNew'){
            return view('admin.user.create',compact('groups'));
        }
        return view('admin.user.edit',compact('user','groups'));
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }
}

and this is the edit.blade.php

@extends('layouts.admin')
@section('styles')
    <!-- Admin styles CSS -->
    <link rel="stylesheet" href="{{asset('css/admin/admin-styles.css')}}">
@stop
@section('content')

    <div class="col-sm-12">
        <div class="row">
            {!! Form::model($user,['method'=>'PATCH','action'=>['[email protected]',$user->id],'class'=>'form-validate form-horizontal']) !!}
            {!!csrf_field()!!}

            {{--Start of button panel--}}
            <div class="subhead">
                <div class="container-fluid">
                    <div id="container-collapse" class="container-collapse"></div>
                    <div class="row-fluid">
                        <div class="span12">
                            <div class="btn-toolbar" id="toolbar">
                                <div class="btn-wrapper" id="toolbar-apply">
                                    <button type="submit" name="submit" value="save" class="btn btn-small btn-success">
                                        <span class="icon-apply icon-white"></span>
                                        {{trans('admin-buttons.DRAC_BUTTON_SAVE')}}</button>
                                </div>
                                <div class="btn-wrapper" id="toolbar-save">
                                    <button class="btn btn-small" type="submit" name="submit" value="saveAndClose">
                                        <span class="icon-save"></span>
                                        {{trans('admin-buttons.DRAC_BUTTON_SAVE_CLOSE')}}</button>
                                </div>
                                <div class="btn-wrapper" id="toolbar-save-new">
                                    <button class="btn btn-small" type="submit" name="submit" value="saveAndNew">
                                        <span class="icon-save-new"></span>
                                        {{trans('admin-buttons.DRAC_BUTTON_SAVE_NEW')}}</button>
                                </div>
                                <div class="btn-wrapper" id="toolbar-cancel">
                                    <a class="btn btn-small" href="{{route('user.index')}}">
                                        <span class="icon-cancel"></span>
                                        {{trans('admin-buttons.DRAC_BUTTON_CANCEL')}}</a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            {{--end button panel--}}
            {{--Validation check--}}
            @include('admin.partials.errorNotification')
            {{--End Validation check--}}
            {{--Success message if everything is saved successfully--}}
            @if(Session::has('success'))
                <div class="alert alert-success">
                    <button type="button" class="close" data-dismiss="alert">x</button>
                    {{Session::get('success')}}
                </div>
            @endif
            {{--end success message--}}

            <div id="tab-panel">
                <ul class="nav nav-tabs">
                    <li class="active">
                        <a href="#account_details" data-toggle="tab">Account Details</a>
                    </li>
                    <li>
                        <a href="#user_groups" data-toggle="tab">Assigned User Groups</a>
                    </li>
                    <li>
                        <a href="#basic_settings" data-toggle="tab">Basic Settings</a>
                    </li>
                </ul>

                <div class="tab-content">
                    {{--User details tab--}}
                    <div class="tab-pane active tabPosition" id="account_details">
                        <div class="col-lg-3 col-md-4">
                            <div class="form-group top-control">
                                <div class="label-container">
                                    <label for="firstName" class="control-label label-left">{{trans('admin.DRAC_ADMIN_FIRSTNAME')}} *</label>
                                </div>
                                <div class="input-control label-left">
                                    <input type="text" name="firstName" id="firstName" class="form-control" value="{{$user->firstName}}" disabled="disabled">
                                </div>
                            </div>
                            <div class="form-group top-control">
                                <div class="label-container">
                                    <label for="lastName" class="control-label label-left">{{trans('admin.DRAC_ADMIN_LASTNAME')}} *</label>
                                </div>
                                <div class="input-control label-left">
                                    <input type="text" name="lastName" id="lastName" class="form-control" value="{{$user->lastName}}" disabled="disabled">
                                </div>
                            </div>
                            <div class="form-group top-control">
                                <div class="label-container">
                                    <label for="login-name" class="control-label label-left">{{trans('admin.DRAC_ADMIN_LOGIN_NAME')}} *</label>
                                </div>
                                <div class="input-control label-left">
                                    <input type="text" name="login_name" id="login_name" class="form-control" value="{{$user->login_name}}" disabled="disabled">
                                </div>
                            </div>
                            <div class="form-group top-control">
                                <div class="label-container">
                                    <label for="password" class="control-label label-left">{{trans('admin.DRAC_ADMIN_PASSWORD')}}</label>
                                </div>
                                <div class="input-control label-left">
                                    <input type="password" name="password" id="password" class="form-control">
                                </div>
                            </div>
                            <div class="form-group top-control">
                                <div class="label-container">
                                    <label for="confirm-password" class="control-label label-left">{{trans('admin.DRAC_ADMIN_CONFIRM_PASSWORD')}}</label>
                                </div>
                                <div class="input-control label-left">
                                    <input type="password" name="confirm-password" id="confirm-password" class="form-control">
                                </div>
                            </div>
                            <div class="form-group top-control">
                                <div class="label-container">
                                    <label for="email" class="control-label label-left">{{trans('admin.DRAC_ADMIN_EMAIL')}} *</label>
                                </div>
                                <div class="input-control label-left">
                                    <input type="email" name="email" id="email" class="form-control" value="{{$user->email}}">
                                </div>
                            </div>
                            <div class="form-group top-control">
                                <div class="label-container">
                                    <label for="registration-date" class="control-label label-left">{{trans('admin.DRAC_ADMIN_REGISTRATION_DATE')}}</label>
                                </div>
                                <div class="input-control label-left">
                                    <input type="text" name="registration-date" id="registration-date" class="form-control" value="{{$user->created_at}}" disabled>
                                </div>
                            </div>
                            <div class="form-group top-control">
                                <div class="label-container">
                                    <label for="last-visit-date" class="control-label label-left">{{trans('admin.DRAC_ADMIN_LAST_VISIT_DATE')}}</label>
                                </div>
                                <div class="input-control label-left">
                                    <input type="text" name="last-visit-date" id="last-visit-date" class="form-control" disabled>
                                </div>
                            </div>
                            <div class="form-group top-control">
                                <div class="label-container">
                                    <label for="last-reset-date" class="control-label label-left">{{trans('admin.DRAC_ADMIN_LAST_RESET_DATE')}}</label>
                                </div>
                                <div class="input-control label-left">
                                    <input type="text" name="last-reset-date" id="last-reset-date" class="form-control" disabled>
                                </div>
                            </div>
                            <div class="form-group top-control">
                                <div class="label-container">
                                    <label for="password-reset-count" class="control-label label-left">{{trans('admin.DRAC_ADMIN_PASSWORD_RESET_COUNT')}}</label>
                                </div>
                                <div class="input-control label-left">
                                    <input type="text" name="password-reset-count" id="password-reset-count" class="form-control" value="{{$user->password_reset_count}}" disabled>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="label-container">
                                    <label for="sendEmail" class="control-label label-left">{{trans('admin.DRAC_ADMIN_RECEIVE_SYSTEM_EMAILS')}}</label>
                                </div>
                                <div class="controls label-left">
                                    <fieldset class="btn-group btn-group-yesno radio" id="sendEmail">
                                            <input type="radio" id="sendEmail0" name="sendEmail" value="1" {{$user->sendEmail ? 'checked=checked' : ''}}>
                                            <label for="sendEmail0">Yes</label>
                                            <input type="radio" id="sendEmail1" name="sendEmail" value="0" {{!$user->sendEmail ? 'checked=checked' : ''}}>
                                            <label for="sendEmail1">No</label>
                                    </fieldset>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="label-container">
                                    <label for="blockUser" class="control-label label-left">{{trans('admin.DRAC_ADMIN_BLOCK_THIS_USER')}}</label>
                                </div>
                                <div class="controls label-left">
                                    <fieldset class="btn-group btn-group-yesno radio" id="blockUser">
                                        @if($user->blockUser == 1)
                                            <input type="radio" id="blockUser0" name="blockUser" value="{{$user->blockUser}}" checked="checked">
                                            <label for="blockUser0">Yes</label>
                                            <input type="radio" id="blockUser1" name="blockUser" value="0">
                                            <label for="blockUser1">No</label>
                                        @else
                                            <input type="radio" id="blockUser0" name="blockUser" value="1">
                                            <label for="blockUser0">Yes</label>
                                            <input type="radio" id="blockUser1" name="blockUser" value="{{$user->blockUser}}" checked="checked">
                                            <label for="blockUser1">No</label>
                                        @endif
                                    </fieldset>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="label-container">
                                    <label for="pwdreset" class="control-label label-left">{{trans('admin.DRAC_ADMIN_REQUIRE_PASSWORD_RESET')}}</label>
                                </div>
                                <div class="controls label-left">
                                    <fieldset class="btn-group btn-group-yesno radio" id="pwdreset">
                                        @if($user->reqPasswordReset == 1)
                                            <input type="radio" id="pwdreset0" name="reqPasswordReset" value="{{$user->reqPasswordReset}}" checked="checked">
                                            <label for="pwdreset0">Yes</label>
                                            <input type="radio" id="pwdreset1" name="reqPasswordReset" value="0">
                                            <label for="pwdreset1">No</label>
                                        @else
                                            <input type="radio" id="pwdreset0" name="reqPasswordReset" value="1">
                                            <label for="pwdreset0">Yes</label>
                                            <input type="radio" id="pwdreset1" name="reqPasswordReset" value="{{$user->reqPasswordReset}}" checked="checked">
                                            <label for="pwdreset1">No</label>
                                        @endif
                                    </fieldset>
                                </div>
                            </div>
                        </div>{{--end account details--}}
                    </div>
                    {{--Assigned user group tabs--}}
                    <div class="tab-pane tabPosition" id="user_groups">
                        <div class="col-sm-3">
                            <div class="checkbox-container">
                                <div class="row">
                                    @foreach($groups as $group)
                                        <div class="control-group">
                                            <div class="input-control label-left chkbox-control button">
                                                <label for="{{$group->name}}" class="form-check-label checkbox-inline align-middle">
                                                    <input type="checkbox" name="groupid[]"
                                                           {{in_array($group->id,$user->groupid) ? 'checked' : ''}}
                                                           value={{$group->id}} class="check-input">{{$group->name}}
                                                </label>
                                            </div>
                                        </div>
                                    @endforeach
                                </div>
                            </div>
                        </div>{{--end assigned user group tab--}}
                    </div>
                    {{--Basic Settings Tab--}}
                    <div class="tab-pane tabPosition" id="basic_settings">
                        <div class="col-sm-3">
                            <div class="form-group">
                                <div class="label-container">
                                    <label for="backend-language" class="control-label label-left">{{trans('admin.DRAC_ADMIN_BACKEND_LANGUAGE')}}</label>
                                </div>
                                <div class="input-control label-left">
                                    <select class="form-control" name="backend-language" id="backend-language">
                                        <option value="1">one</option>
                                        <option value="2">two</option>
                                        <option value="3">three</option>
                                        <option value="4">four</option>
                                        <option value="5">five</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="label-container">
                                    <label for="front-end-language" class="control-label label-left">{{trans('admin.DRAC_ADMIN_FRONTEND_LANGUAGE')}}</label>
                                </div>
                                <div class="input-control label-left">
                                    <select class="form-control" name="front-end-language" id="front-end-language">
                                        <option value="1">one</option>
                                        <option value="2">two</option>
                                        <option value="3">three</option>
                                        <option value="4">four</option>
                                        <option value="5">five</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="label-container">
                                    <label for="time-zone" class="control-label label-left">{{trans('admin.DRAC_ADMIN_TIME_ZONE')}}</label>
                                </div>
                                <div class="input-control label-left">
                                    <select class="form-control" name="timezone">
                                        @foreach(timezone_identifiers_list() as $timezone)
                                            <option value="{{$timezone}}"{{$timezone == $user->timezone ? 'selected' : ''}}>{{$timezone}}</option>
                                        @endforeach
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>{{--end basic settings--}}
                </div>
            </div>
            {!! Form::close() !!}
            {{--</form>--}}
        </div>
    </div>
@stop

@section('scripts')
    <script src="{{asset('js/admin/users.js')}}"></script>
@stop

6th May, 2017

dcaldessa left a reply on Validation On Update With Unique ID • 1 year ago

ok this is my UserValidationStore class which is working correctly.

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class UserValidationStore extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return[
            'firstName' => 'required',
            'lastName' => 'required',
            'login_name' => 'required|unique:users,login_name',
            'password' => 'required|min:8',
            'confirm-password' => 'required|min:8|same:password',
            'email' => 'required|email|unique:users,email'
        ];
    }
}

The issue is with my UserValidationUpdate Request Class.

Which you and nash have provided solutions for, this is the way that it looks now .

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class UserValidationUpdate extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [

            'password' => 'min:8',
            'confirm-password' => 'min:8|same:password',
            'email' => [
                'required',
                Rule::unique('users')->ignore($this->user()->id),
            ],
        ];
    }
}

When hitting the save button with out changing anything on the user information i get

ErrorException in UserValidationUpdate.php line 33:
Trying to get property of non-object

I do not know why I am getting the error on Update of the user

I did diedump this and it returned null

$this->user()->id

i then changed it up to

$this->user

and it returned the Id of the user and when I clicked the save button without changing any of the user data. I get the flash message that the user was successfully saved. which is the correct action that should occur.

but when i deliberately change the email address to one that already exists in the database it should come back with an error alert that this email already exists right ?

When I click save it just goes to a blank page with the url showing


drac/admin/user/{id of user}

like it is trying to go back but it cannot render the page correctly.

is there anywhere else i should be looking to get more information on what is going on?

dcaldessa left a reply on Validation On Update With Unique ID • 1 year ago

Also something else i have noticed is

$this->user() 

returns null on a dd

but when i use

$this->user

it returns the Id of the user when dd.

So is there something set wrong somewhere else in my application ?

dcaldessa left a reply on Validation On Update With Unique ID • 1 year ago

So i have tried the above solutions that have been provided ..

   return [

            'email' => 'required|email|unique:users,id,'.$this->user()->id,

    ];

returns an error

ErrorException in UserValidationUpdate.php line 41: Trying to get property of non-object

Also tried it with the rule syntax and still get the same error

I did try using this


$user = User::find($this->user);

 'email' => [
                'required',
                Rule::unique('users')->ignore($user->id),

and it throws no errors and just returns me to the index page as if i were clicking the save and close button.

5th May, 2017

dcaldessa started a new conversation Validation On Update With Unique ID • 1 year ago

I am working on a project but am stuck at the moment on validation using a request file.

I am trying to pass the unique attribute of email on update of a user. If the user does not change his/her email but say changes their password I want to be able to update the record with out it throwing a unique id error or stating that the record already exists.

I have tried using the Rule solution in the laravel documentation but I get an error stating Class 'Composer\DependencyResolver\Rule' not found, we have determined that the unique method does not exist for rule. Not sure how I am supposed to get around this error thus I cannot use the Rule:: methods as stated in the documentation.

I have found some other solutions on this site but none of them seem to work. So making a post to see if I can get some insight on what to do next ..

My UserValidationUpdate request looks like this

'''php public function rules() { $user = User::find($this->user);

    return [

            'email' => 'required|email|unique:users,id,'.$user->id,

    ];

'''

and the update method on my AdminUserController is formatted like this

'''php

public function store(UserValidationStore $request) { $user = new User; $checkboxes = $request->input('group');

        $user->firstName = $request->firstName;
        $user->lastName = $request->lastName;
        $user->login_name = $request->login_name;
        $user->password = Hash::make($request->password);
        $user->email = $request->email;
        $user->group_id = serialize($checkboxes);
        $user->sendEmails = Input::get('sendEmail');
        $user->blockUser = Input::get('blockUser');
        $user->reqPasswordReset = Input::get('reqPasswordReset');
        $user->timezone = $request->timezone;
        $user->save();

    Session::flash('success', 'User successfully saved.');

    $groups = UserGroup::all();

    if ($request->get('submit') == 'saveAndClose'){
        return view('admin.user.index');
    }elseif ($request->get('submit') == 'saveAndNew'){
        return view('admin.user.create',compact('user','groups'));
    }
    return view('admin.user.edit',compact('user','checkboxes','groups'));
}

'''

By all accounts it looks to be setup correctly based on the suggestions that I have read in other posts. But when I go to test it by removing the data in the email input and hit save I just get a blank page with the correct uri in the address bar i.e admin/user/32 not sure why it is blank just again looking for some suggestions in figuring this out ..

thanks

dcaldessa.

Edit Your Profile
Update

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