public function firstOrCreate(array $attributes, array $joining = [], $touch = true)
    {
        if (is_null($instance = $this->where($attributes)->first())) {
            $instance = $this->create($attributes, $joining, $touch);
        }

        return $instance;
    }
public function firstOrCreate(array $attributes, array $joining = [], $touch = true)
    {
        if (is_null($instance = $this->where($attributes)->first())) {
            $instance = $this->create($attributes, $joining, $touch);
        }

        return $instance;
    }
public function firstOrCreate ( array $ attributes , array $ joining = [ ] , $ touch = true ) { if ( is_null ( $ instance = $ this -> where ( $ attributes ) -> first ( ) ) ) { $ instance = $ this -> create ( $ attributes , $ joining , $ touch ) ; } return $ instance ; }
Get the first related record matching the attributes or create it.

@param  array  $attributes
@param  array  $joining
@param  bool   $touch
@return \Illuminate\Database\Eloquent\Model
Get the first related record matching the attributes or create it .