Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel unique validation

/**
 * Store a new blog post.
 *
 * @param  Request  $request
 * @return Response
 */

public function store(Request $request)
{
    $validatedData = $request->validate([
        'title' => 'required|unique:posts|max:255',
        'body' => 'required',
    ]);

    // The blog post is valid...
}
Comment

laravel rule unique ignore

use IlluminateSupportFacadesValidator;
use IlluminateValidationRule;

Validator::make($data, [
    'email' => [
        'required',
        Rule::unique('users')->ignore($user->id),
    ],
]);
Comment

laravel unique validation

unique:table,column,except,idColumn

############## Example : ################

############### For Updating  
//rules
'email' => 'unique:users,email_address,' . $userId,

############### For Creating 
//rules
'email' => 'unique:users,email_address',
Comment

laravel rule unique where

'required|email|unique:company_users,email_address,NULL,id,company_id,' . $request->company_id
Comment

unique validation laravel

<?php
  
namespace AppHttpRequests;
  
use IlluminateFoundationHttpFormRequest;
  
class StoreUserRequest 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' => 'required',
                'username' => 'required|min:8',
                'email'=>'required|email|unique:users,email,NULL,id,deleted_at,NULL'
            ];
    }
}
Comment

Laravel unique with Validation rule

'name'        => 'required|max:150|unique:course_lessons,name,NULL,id,course_id,' . request('course_id'),
 "<input_filed_name>" => "valiadtionRule"|"ValidationRule"|"unique:<tableName>,<validateableField>,<ignoreableID>,<tablePrimaryKey>,<column1>,<column1Value>,<column2>,<column2Value>"
Comment

PREVIOUS NEXT
Code Example
Php :: Sending HTML Code Through JSON 
Php :: php 7 The each() function is deprecated. 
Php :: c# to php 
Php :: laravel sync with attributes 
Php :: php using composer autoload 
Php :: get HTML select value to PHP 
Php :: square root 
Php :: how to enable autoreload on save laravel 
Php :: htaccess rewrite optional parameters 
Php :: Call to undefined method CI_DB_mysqli_result::order_by() 
Php :: document ready wordpress 
Php :: laravel log error 
Php :: dynamic function name php 
Php :: withcookie function in php 
Php :: Laravel Extract Values From Collection Using Pluck() with Relationship 
Php :: submit form and show results on same page without refresh 
Php :: validate number should by 12 digit in php 
Php :: check if second array has all the values from the first element php 
Php :: array_diff php 
Php :: mysql gone away error in php 
Php :: how to create route in laravel 
Php :: php typecast class 
Php :: Publish Spatie Laravel Permission 
Php :: install laravel scout 
Php :: comment installer laravel avec docker 
Php :: php email sender 
Php :: pagination javascript php 
Php :: create an email addresses php 
Php :: :: in php 
Php :: API json data show in laravel 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =