Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [inny][Laravel 5.2] Unique (database) pomoc w zbudowaniu warunku
wujek2009
post
Post #1





Grupa: Zarejestrowani
Postów: 350
Pomógł: 31
Dołączył: 23.05.2010

Ostrzeżenie: (0%)
-----


Hej,

próbuje napisać regułę walidacyjną unique (dla db) ~ https://laravel.com/docs/5.2/validation#rule-unique

  1. public function rules()
  2. {
  3. $userObject = (..);
  4.  
  5. $rules = [
  6. 'iso' => 'required',
  7. 'tax_number' => 'required|unique:user,tax_number (IMG:style_emoticons/default/questionmark.gif) ,'. $userObject->id
  8. ];
  9.  
  10. return $rules;
  11. }


sql'owo ma to wyglądać tak:
  1. # where tax_number = "WARTOSC_Z_FORMULARZA" AND iso = "WARTOSC_ISO_Z_FORMULARZA" AND id != $userObject->id


w docu jest przykład:
Kod
'email' => 'unique:users,email_address,NULL,id,account_id,1'


tylko nie wiem dlaczego tam jest NULL?

Ten post edytował wujek2009 5.04.2016, 16:52:00
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.08.2025 - 22:41