Default password in Laravel - laravel

I would like to configure a default password because in the project I am working on, It is the admin who is to create accounts for users.
Of course, if a put a default value on my model, It will not hash the password. How else can I approach this
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('POBox');
$table->string('password');
$table->rememberToken();
$table->unsignedBigInteger('address_id')->index();
$table->unsignedInteger('role_id');
$table->timestamps();
$table->foreign('address_id')->references('id')->on('addresses');
});
}

Have the Admin only create the user and then email the New user a password reset.
Form:
<form method="POST" action="{{ route('admin.user.store') }}" class="bg-white shadow-md rounded px-8 pt-6 pb-8 mb-4">
#csrf
<div class="form-group">
<div class="row">
<div class="col-md-6">
<label for="first_name" class="no-pad-left col-form-label white-txt muli w4">First Name</label>
<input id="first_name" type="text" class="form-control{{ $errors->has('first_name') ? ' is-invalid' : '' }}" name="first_name" placeholder="Enter First Name" value="{{ old('first_name') }}" required autofocus>
#if ($errors->has('first_name'))
<span class="invalid-feedback appearance-none block w-full bg-gray-200 text-gray-700 border border-red-500 rounded py-3 px-4 mb-3 leading-tight focus:outline-none focus:bg-white">
<strong>{{ $errors->first('first_name') }}</strong>
</span>
#endif
</div>
<div class="col-md-6">
<label for="last_name" class="no-pad-left col-form-label white-txt muli w4">Last Name</label>
<input id="last_name" type="text" class="form-control{{ $errors->has('last_name') ? ' is-invalid' : '' }}" name="last_name" placeholder="Enter Last Name" value="{{ old('last_name') }}" required autofocus>
#if ($errors->has('last_name'))
<span class="invalid-feedback appearance-none block w-full bg-gray-200 text-gray-700 border border-red-500 rounded py-3 px-4 mb-3 leading-tight focus:outline-none focus:bg-white">
<strong>{{ $errors->first('last_name') }}</strong>
</span>
#endif
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-md-12">
<label for="email" class="no-pad-left col-form-label white-txt muli w4">E-Mail Address</label>
<input id="email" type="email" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email" placeholder="Enter Email Address" value="{{ old('email') }}" required>
#if ($errors->has('email'))
<span class="invalid-feedback appearance-none block w-full bg-gray-200 text-gray-700 border border-red-500 rounded py-3 px-4 mb-3 leading-tight focus:outline-none focus:bg-white">
<strong>{{ $errors->first('email') }}</strong>
</span>
#endif
</div>
</div>
</div>
<div class="flex">
<button type="submit" class="bg-yellow-500 hover:bg-yellow-700 text-navy-500 md:w-1/4 sm:w-full w-full font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline shadow-lg" type="button">
Create User
</button>
</div>
</form>
Controller
public function adminUserStore(Request $request){
$validatedData = $request->validate([
'first_name'=> 'required|string|max:255',
'last_name'=> 'required|string|max:255',
'email' => 'required|string|email|max:255|unique:users',
]);
$quickpass = substr( str_shuffle( str_repeat( 'abcdefghijklmnopqrstuvwxyz0123456789', 10 ) ), 0, 10 );
$adminName = Auth::user()->first_name.' '.Auth::user()->last_name;
$newuser = User::create([
'first_name'=> $request->first_name,
'last_name'=> $request->last_name,
'email' => $request->email,
'password' => Hash::make($quickpass),
'role_id' => '0',
'added_by' => $adminName,
]);
Mail::to($newuser->email)
->send(new NewUserPassReset(
$request->input('first_name'),
$request->input('last_name'),
$request->input('email')
));
return back()->with('success','The user has been created and a password reset email has been sent to them.');
}
You should be able to figure out the email part. Then in the email that is sent to the new user, include a link to the Reset Password route.
That's how I do it.

You can use default values in a Model.
User.php
public class User extends Model
{
protected $attributes = [
'password' => Hash::make(Str::random(40))
];
}
Str::random will give you a random 40-chars String. You can change this to anything you like.
Hash::make() will hash the String so Laravel can check the Hash when User tries to login.

Related

Laravel Livewire sync($request->input)

public function modelData()
{
$user = User::create([
'name' => $this->name,
'npm' => $this->npm,
'email' => $this->email,
'jurusan' => $this->jurusan,
'fakultas' => $this->fakultas,
'password' => Hash::make($this->password),
]);
$user->roles()->sync($this->input('roles', []));
}
this is my code. please someone help me how to use request -> input in livewire
class Usermanajemen extends Component
{
public $role = [];
public $users;
public $name;
public $npm;
public $email;
public $password;
public $jurusan;
public $fakultas;
use WithPagination;
public $modalFormVisible = false;
public $modelid;
public function render()
{
$this->users = User::orderBy('created_at', 'DESC')->get();
$roles = Role::pluck('title', 'id');
return view('livewire.usermanajemen', compact('roles'));
}
public function create()
{
$this->validate();
User::create($this->modelData());
$this->modalFormVisible = false;
$this->reset();
}
public function closeModal()
{
$this->modalFormVisible = false;
}
public function createShowModal()
{
$this->resetValidation();
$this->reset();
$this->modalFormVisible = true;
}
public function mount()
{
$this->resetPage();
}
/**
* The update function.
*
* #return void
*/
public function rules()
{
return [
'name' => ['required', 'string', 'max:255'],
'npm' => ['required', 'numeric', Rule::unique('users', 'npm')->ignore($this->modelid)],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => ['required', 'min:6'],
'jurusan' => 'required',
'fakultas' => 'required',
];
}
/**
* The data for the model mapped
* in this component.
*
* #return void
*/
public function modelData()
{
$user = User::create([
'name' => $this->name,
'npm' => $this->npm,
'email' => $this->email,
'jurusan' => $this->jurusan,
'fakultas' => $this->fakultas,
'password' => Hash::make($this->password),
]);
$user->roles()->sync($this->role);
}
}
this is my livewire usermanajemen i change my role in create and add role=[]in public
<form>
<div class="bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4">
<div class="">
<div class="mb-4">
<label for="name" class="block text-gray-700 text-sm font-bold mb-2">Nama:</label>
<input type="text" class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" id="name" wire:model="name">
#error('name') <span class="text-red-500">{{ $message }}</span>#enderror
</div>
<div class="mb-4">
<label for="npm" class="block text-gray-700 text-sm font-bold mb-2">Npm:</label>
<input type="text" class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" id="npm" wire:model="npm">
#error('npm') <span class="text-red-500">{{ $message }}</span>#enderror
</div>
<div class="mb-4">
<label for="email" class="block text-gray-700 text-sm font-bold mb-2">Email:</label>
<input type="email" class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" id="email" wire:model="email">
#error('email') <span class="text-red-500">{{ $message }}</span>#enderror
</div>
<div class="mb-4">
<label for="password" class="block text-gray-700 text-sm font-bold mb-2">Password:</label>
<input type="password" class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" id="password" wire:model="password">
#error('password') <span class="text-red-500">{{ $message }}</span>#enderror
</div>
<div class="mb-4">
<label for="jurusan" class="block text-gray-700 text-sm font-bold mb-2">Jurusan:</label>
<input type="text" class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" id="jurusan" wire:model="jurusan">
#error('jurusan') <span class="text-red-500">{{ $message }}</span>#enderror
</div>
<div class="mb-4">
<label for="fakultas" class="block text-gray-700 text-sm font-bold mb-2">Fakultas:</label>
<input type="text" class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" id="fakultas" wire:model="fakultas">
#error('fakultas') <span class="text-red-500">{{ $message }}</span>#enderror
</div>
<div class="px-4 py-5 bg-white sm:p-6">
<label for="role" class="block font-medium text-sm text-gray-700">Roles</label>
<select wire:model = "role" name="role" id="role" class="form-multiselect block rounded-md shadow-sm mt-1 block w-full" multiple="multiple">
#foreach($roles as $id => $role)
<option value="{{ $id }}"{{ in_array($id, old('roles', [])) ? ' selected' : '' }}>{{ $role }}</option>
#endforeach
</select>
#error('roles')
<p class="text-sm text-red-600">{{ $message }}</p>
#enderror
</div>
</div>
</div>
this is my blade file for create
i change in my livewire and my blade and still error but users added
Why do you want to use request ?
You can add a property like public roles = []; in the class
and bind this property with select/checkbox ie: <select wire:model="role" multiple>
and then you can use sync like this : $user->roles()->sync($this->roles);
PS: I assumed that you already defined many to many relationship

validation error regarding the validation file in laravel

I am calling a validation request but i am getting this error.
Method Illuminate\Validation\Validator::validateFile, does not exist.
My UserRequest
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use App\Http\Controllers\ProfileController;
class UserRequest 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 [
'name'=> 'string|required|max:255',
'username'=> 'string|required|max:255|alpha_dash',
'avatar'=>'file,|mimes:jpeg,png,gif,jpg|max:2048',
'email'=> 'email|required|string',
'password'=>'required|min:10|string|confirmed',
'background'=>'file,|mimes:jpeg,png,gif,jpg|max:2048',
'description'=>'string|max:255'
];
}
public function messages()
{
return [
'name.required' => 'A name is required',
'username.required' => 'A username is required',
'email.required' => 'An email is required',
'password.required' => 'A password is required',
'description' => 'A description should be string',
];
}
}
My Controller
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests\UserRequest;
use Illuminate\Http\File ;
use App\User;
use Hash;
use Session;
public function update(User $user,UserRequest $request)
{
$user->update(['name'=>request('name'),'username'=>request('username'),'email'=>request('email'),'password'=> Hash::make(request('password')),'avatar'=>$path,'background'=>$background,'description'=>request('description')]);
Session::flash('success', 'You have successfully updated a post!');
return redirect($user->path())->with(['message'=>'Profile updated']);
}
my blade
#extends('layouts.app')
#section('content')
<h1 class="text-gray-700 text-2xl font-bold text-center">Edit Profile</h1>
<div class="mt-5 mb-6">
<img src="{{$user->avatar()}}" alt=""
class="rounded-full mr-2 bottom-0 transform "
width="150px" style="transform: translateX(16.5rem);" >
</div>
<form method="POST" action="{{$user->path() }}" enctype="multipart/form-data">
#csrf
#method('PATCH')
<div id="flip" class="p-5 bg-gray-200">Basic Info</div>
<div id="panel">
<div class="mb-6 mt-6">
<label for="avatar">Select Profile to Upload</label>
<input id="avatar" type="file" class="#error('avatar') is-invalid #enderror" name="avatar">
#error('avatar')
<div class="text-red-800">{{ $message }}</div>
#enderror
</div>
<div class="mb-6">
<label for="name">Name</label>
<input id="name" type="text" class="#error('name') is-invalid #enderror border border-gray-400 p-2 w-full" name="name" value="{{$user->name}}">
#error('name')
<div class="text-red-800">{{ $message }}</div>
#enderror
</div>
<div class="mb-6">
<label for="username">Username</label>
<input id="username" type="text" name="username" class="#error('username') is-invalid #enderror border border-gray-400 p-2 w-full" value="{{$user->username}}">
#error('username')
<div class="text-red-800">{{ $message }}</div>
#enderror
</div>
<div class="mb-6">
<label for="email">Email</label>
<input id="email" type="email" name="email" class="#error('email') is-invalid #enderror border border-gray-400 p-2 w-full" value="{{$user->email}}">
#error('email')
<div class="text-red-800">{{ $message }}</div>
#enderror
</div>
<div class="mb-6">
<label for="password">Password</label>
<input id="password" type="password" name="password" class="#error('password') is-invalid #enderror border border-gray-400 p-2 w-full" >
#error('password')
<div class="text-red-800">{{ $message }}</div>
#enderror
</div>
<div class="mb-6">
<label for="password-confirm">Confirm Password</label>
<input id="password-confirm" type="password" name="password-confirm" class="#error('password-confirm') is-invalid #enderror border border-gray-400 p-2 w-full" >
#error('password-confirm')
<div class="text-red-800">{{ $message }}</div>
#enderror
</div>
</div>
<div id="main" class="p-5 bg-gray-200">Background</div>
<div id="child">
<div class="mb-6 mt-6">
<label for="background">Select Background image to Upload</label>
<input id="background" type="file" class="#error('background') is-invalid #enderror" name="background">
#error('background')
<div class="alert alert-danger">{{ $message }}</div>
#enderror
</div>
<div class="mb-6">
<label for="description">Description</label>
<input id="description" type="text" name="description" class="#error('description') is-invalid #enderror border border-gray-400 p-2 w-full" value="{{$user->description}}">
#error('description')
<div class="alert alert-danger">{{ $message }}</div>
#enderror
</div>
</div>
<div class="mt-6">
<button type="submit" class="bg-blue-500 text-white rounded py-2 px-4 hover:bg-blue-800'">Submit</button>
</div>
</form>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#flip").click(function(){
$("#panel").slideToggle("slow");
});
$("#main").click(function(){
$("#child").slideToggle("slow");
});
});
</script>
#endsection
I have tried the solutions available on stack overflow but still none of them work
Does anyone know why am i getting this error?
Any help will be appreciated.
Remove comma in these validation lines.
'avatar'=>'file,|mimes:jpeg,png,gif,jpg|max:2048',
'background'=>'file,|mimes:jpeg,png,gif,jpg|max:2048',
Add password.confirmed in messages array.
'password.confirmed' => 'YOUR ERROR MESSAGE',

Reset password manually via answering the security questions without sending email - Laravel/auth

I am currently developing a simple Bookstore application with a few numbers of users on which sending emails are not needed because it will be implemented in local system so is there any way to customize laravel-auth for password reset function by adding a few security questions fields where user can reset his/her password without sending reset links via email.
Any kind of help will be highly appreciated.
here I tried the below code but id did not work
Code in web.php
Route::post('/main/checklogin', 'UserController#chekQuestions');
Code in userContoller
public function chekQuestions(Request $request)
{
$request->validate( [
'email' => 'required|string|email',
'answerQuestionOne' => 'required|string|confirmed',
'answerQuestionTwo' => 'required|string'
] );
$user = User::first();
if($user->email == $request->email && $user->answerQuestionOne == $request->answerQuestionOne && $user->answerQuestionTwo == $request->answerQuestionTwo )
{
// $userEmail = DB::table( 'password_resets' )->where( 'token', $user->token );
// return view('auth.password.reset',compact($userEmail));
return view('auth.password.reset');
}
return response()->json( [
'error' => true,
'message' => 'We cannot find a user with that Email Address'
], 404 );
}
Code in reset password.blade
<div id="register" class="animate form registration_form">
<section class="login_content">
<form method="POST" action="{{ url('/main/checklogin') }}" >
#csrf
<h3>د پټ نو بیا راګرځولو لپاره لاندی امنتی پوښتنو ته ځواب ورکړی </h3>
<div class="form-group has-feedback">
<input id="email" type="email" placeholder=" ایمل" class="form-control #error('email') is-invalid #enderror" name="email" value="{{ old('email') }}" required autocomplete="email" autofocus>
#error('email')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
<div class="form-control-feedback">
<i class="fa fa-envelope-o text-muted"></i>
</div>
</div>
<div>
<input id="answerQuestionOne" placeholder="لومړۍ امنیتي پوښتنه" type="text" class="form-control #error('answerQuestionOne') is-invalid #enderror" name="answerQuestionOne" value="{{ old('answerQuestionOne') }}" required autocomplete="answerQuestionOne" autofocus>
#error('answerQuestionOne')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
<div>
<input id="answerQuestionTwo" placeholder="دوهمه امنیتي پوښتنه " type="text" class="form-control #error('answerQuestionTwo') is-invalid #enderror" name="answerQuestionTwo" value="{{ old('answerQuestionTwo') }}" required autocomplete="answerQuestionTwo" autofocus>
#error('answerQuestionTwo')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
<button type="submit" class="btn btn-default btn-block">خوندی کړی </button>
<div class="clearfix"></div>
<div class="separator">
<p class="change_link">
تاسو دمخه غړی یاست ننوتل
</p>
<div class="clearfix"></div>
<br />
</form>
</section>
</div>
You don't need Laravel implementation for this. Just Find a user with the given email and check the answers. After that update the user record with the new password.
In order to fetch user you should do this:
$data = $request->validate( [
'email' => 'required|string|email',
'answerQuestionOne' => 'required|string|confirmed',
'answerQuestionTwo' => 'required|string'
] );
$user = User::where(['email' => $data['email'])->first();
After this just check the answers.
You also need to take the new password from user.

Adding new fields into Laravel 5.8 defaut user table

I have updated the laravel users table by adding few more field.usertype was one of it. Then I have updated the User model fillable field and also I have added required input types into my form. After all of these I have run php artisan migrate:refresh after that I can see that my table field also updated. But when I submit the form it generates the below error saying usertype dosent have a default value. usertype field is not a null filed .Can anyone say me whats wrong in this. For more references please refer below codes.
migration
Schema::create('users', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
//added by myself
$table->string('usertype');
$table->boolean('activestatus')->default(false);
//
$table->rememberToken();
$table->timestamps();
});
User Model
protected $fillable = [
'name',
'email',
'password',
'usertype',
];
User Registration form
#csrf
<input type="text" name="usertype" id="hiddenUserType" value="a" hidden/>
<div class="form-group{{ $errors->has('name') ? ' has-danger' : '' }}">
<div class="input-group input-group-alternative mb-3">
<div class="input-group-prepend">
<span class="input-group-text"><i class="ni ni-hat-3"></i></span>
</div>
<input class="form-control{{ $errors->has('name') ? ' is-invalid' : '' }}" placeholder="{{ __('Name') }}" type="text" name="name" value="{{ old('name') }}" required autofocus>
</div>
#if ($errors->has('name'))
<span class="invalid-feedback" style="display: block;" role="alert">
<strong>{{ $errors->first('name') }}</strong>
</span>
#endif
</div>
<div class="form-group{{ $errors->has('email') ? ' has-danger' : '' }}">
<div class="input-group input-group-alternative mb-3">
<div class="input-group-prepend">
<span class="input-group-text"><i class="ni ni-email-83"></i></span>
</div>
<input class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" placeholder="{{ __('Email') }}" type="email" name="email" value="{{ old('email') }}" required>
</div>
#if ($errors->has('email'))
<span class="invalid-feedback" style="display: block;" role="alert">
<strong>{{ $errors->first('email') }}</strong>
</span>
#endif
</div>
<div class="form-group{{ $errors->has('password') ? ' has-danger' : '' }}">
<div class="input-group input-group-alternative">
<div class="input-group-prepend">
<span class="input-group-text"><i class="ni ni-lock-circle-open"></i></span>
</div>
<input class="form-control{{ $errors->has('password') ? ' is-invalid' : '' }}" placeholder="{{ __('Password') }}" type="password" name="password" required>
</div>
#if ($errors->has('password'))
<span class="invalid-feedback" style="display: block;" role="alert">
<strong>{{ $errors->first('password') }}</strong>
</span>
#endif
</div>
<div class="form-group">
<div class="input-group input-group-alternative">
<div class="input-group-prepend">
<span class="input-group-text"><i class="ni ni-lock-circle-open"></i></span>
</div>
<input class="form-control" placeholder="{{ __('Confirm Password') }}" type="password" name="password_confirmation" required>
</div>
</div>
{{-- <div class="text-muted font-italic">
<small>{{ __('password strength') }}: <span class="text-success font-weight-700">{{ __('strong') }}strong</span></small>
</div> --}}
<div class="row my-4">
<div class="col-12">
<div class="custom-control custom-control-alternative custom-checkbox">
<input class="custom-control-input" id="customCheckRegister" type="checkbox">
<label class="custom-control-label" for="customCheckRegister">
<span class="text-muted">{{ __('I agree with the') }} {{ __('Privacy Policy') }}</span>
</label>
</div>
</div>
</div>
<div class="text-center">
<button type="submit" class="btn btn-primary mt-4">{{ __('Create account') }}</button>
</div>
</form>
Usercontroller
public function store(UserRequest $request, User $model)
{
$model->create($request->merge([
'password' => Hash::make($request->get('password'))
])->all());
return redirect()->route('user.index')
->withStatus(__('User successfully created.'));
}
This is the error it generates while I try to submit the form
SQLSTATE[HY000]: General error: 1364 Field 'usertype' doesn't have a
default value (SQL: insert into users (name, email, password,
updated_at, created_at) values (Nipun Tharuksha, nipun#gmail.com,
$2y$10$fHtc0yTpAFrGcO7dfg1qRe.EYZY/UNY4Ygn5qvUvcCSwoHjUjB6Gu,
2019-04-19 15:36:36, 2019-04-19 15:36:36))
DB
As the error says you are not providing any value for the usertype column, and you are trying to save it with null value. So in that case you can change the migration to allow null by default like this:
$table->string('usertype')->nullable();
And once you change the migration you will have to re-run it using:
php artisan migrate:fresh
Warning: Keep in mind that this will destroy your current data.
Thanks for commenting on this. I was updating Controller UserController . But as #tharakadilshan mentioned I updated mt RegisterController and now its working. Once again thanks for all the comments.
Thanks

how should i give input box red colour in validation in laravel5.4

When user click on the submit button I want to give that text box color as red.
but Laravel comes up with the validation with message..
How can we do the validation as red color text box?
Here is my validation in controller:
protected function validator(array $data) {
return Validator::make($data, [
'first_name' => 'required|max:255',
'last_name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|min:6|confirmed',
'contact_no' => 'required|numeric',
]);
}
here is my view:
<div class="form-group{{ $errors->has('first_name') ? ' has-error' : '' }}">
<label for="name" class="col-md-4 control-label">First Name</label>
<div class="col-md-6">
<input id="first_name" type="text" class="form-control" name="first_name" value="{{ old('name') }}" placeholder="first name" required autofocus>
#if ($errors->has('first_name'))
<span class="help-block">
<strong>{{ $errors->first('first_name') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group{{ $errors->has('last_name') ? ' has-error' : '' }}">
<label for="name" class="col-md-4 control-label">Last Name</label>
<div class="col-md-6">
<input id="last_name" type="text" class="form-control" name="last_name" value="{{ old('last_name') }}" placeholder="last name" required autofocus>
#if ($errors->has('name'))
<span class="help-block">
<strong>{{ $errors->first('name') }}</strong>
</span>
#endif
</div>
</div>
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
<label for="email" class="col-md-4 control-label">E-Mail Address</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control" name="email" value="{{ old('email') }}" placeholder="email" required>
#if ($errors->has('email'))
<span class="help-block">
<strong>{{ $errors->first('email') }}</strong>
</span>
#endif
</div>
</div>
Can any one help me..please
Laravel will addclass has-error according to following line form-group{{ $errors->has('...') ? ' has-error' : '' }}, So you just need to add CSS style.
.has-error .form-control {
border-color: #a94442;
}

Resources