First Or Create

前端 未结 4 1594
耶瑟儿~
耶瑟儿~ 2020-12-02 15:18

I know using:

User::firstOrCreate(array(\'name\' => $input[\'name\'], \'email\' => $input[\'email\'], \'password\' => $input[\'password\']));
         


        
4条回答
  •  离开以前
    2020-12-02 15:39

    firstOrCreate() checks for all the arguments to be present before it finds a match.

    If you only want to check on a specific field, then use firstOrCreate(['field_name' => 'value']) like

    $user = User::firstOrCreate([
        'email' => 'abcd@gmail.com'
    ], [
        'firstName' => 'abcd',
        'lastName' => 'efgh',
        'veristyName'=>'xyz',
    ]);
    
    

    Then it check only the email

提交回复
热议问题