“Es gibt keine Laravel -Validierung” Code-Antworten

Laravel existiert Validierung

'state_id' => 'exists:states,id'
Lokesh003

Laravel Einzigartige Validierung

/**
 * 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...
}
Handsome Hawk

Die Validierung existiert nicht mit diesem Ausweis Laravel

$e = Subscription::find($request->subscription_id);
$rules = [
  'subscription_id' => 'required|integer|exists:subscriptions,id',
  'date' => 'required|date|after:yesterday',
  'date' => Rule::unique('member_attendances')->where(function ($query) use ($e) {
              return $query->where('member_id', $e->member_id);
})
//|unique:member_attendances,date,'.$e->member_id . ',member_id',
];
Basel Rabia

Laravel -Validierungstypen

# <values> = foo,bar,...
# <field> = array field
# <characters> = amount of characters

# accepted					           # active_url
# after:<tomorrow>			           # after_or_equal:<tomorrow>
# alpha						           # alpha_dash
# alpha_num					           # array
# bail 					               # before:<today>
# before_or_equal:<today>              # between:min,max
# boolean					           # confirmed
# date						           # date_equals:<today>
# date_format:<format> 		           # different:<name>
# digits:<value>			           # digits_between:min,max
# dimensions:<min/max_with>	           # distinct
# email						           # ends_with:<values>
# exclude_if:<field>,<value>           # exclude_unless:<field>,<value>
# exists:<table>,<column>	           # file
# filled					           # gt:<field>
# gte:<field>				           # image
# in:<values>				           # in_array:<field>
# integer					           # ip
# ipv4                                 # ipv6  
# json						           # lt:<field>
# lte:<field>       		           # max:<value>
# mimetypes:video/avi,...	           # mimes:jpeg,bmp,png
# min:<value>				           # not_in:<values>
# not_regex:<pattern> 		           # nullable
# numeric					           # password:<auth guard>
# present					           # regex:<pattern>
# required					           # required_if:<field>,<value>
# required_unless:<field>,<value>      # required_with:<fields>
# required_with_all:<fields>	       # required_without:<fields>
# required_without_all:<fields>        # same:<field>
# size:<characters>			           # starts_with:<values>
# string						       # timezone
# unique:<table>,<column>		       # url
# uuid
TheDutchScorpion

Es gibt keine Laravel -Validierung

//create a rule if you're going to use it again
php artisan make:rule CompanyPackageNotExistsRule

//FormRequest
'company_id' => ['required','integer','exists:companies,id', new CompanyPackageNotExistsRule()],

public function passes($attribute, $value)
{
	return !CompanyPackage::where('company_id', $value)->exists();
}
  
public function message()
{
 return 'You have already purchased a package.';
}

//or use directly

'company_id' => ['required','integer','exists:companies,id', function ($attribute, $value, $fail) {
  if (CompanyPackage::where('company_id', $value)->exists()) {
  	$fail('You have already purchased a package.');
  }
}]
Murat Çakmak

Ähnliche Antworten wie “Es gibt keine Laravel -Validierung”

Fragen ähnlich wie “Es gibt keine Laravel -Validierung”

Weitere verwandte Antworten zu “Es gibt keine Laravel -Validierung” auf PHP

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen