Skip to content

Instantly share code, notes, and snippets.

@guanqun
Created February 17, 2014 14:40
Show Gist options
  • Save guanqun/9051823 to your computer and use it in GitHub Desktop.
Save guanqun/9051823 to your computer and use it in GitHub Desktop.
public static function firstByName($name)
{
$instance = static::firstByAttributes(array('user_id' => $name));
return $instance ?: null;
}
@guanqun
Copy link
Author

guanqun commented Feb 17, 2014

findOrFail() parameter is a primary key

firstOrCreate() parameter is an attribute array
firstOrNew() parameter is an attribute array

@guanqun
Copy link
Author

guanqun commented Feb 17, 2014

findByAttributesOrFail()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment