public function first_or_create( array $attributes ) {

		$model = $this->where( $attributes )->first();

		if ( $model ) {
			return $model;
		}

		$model = new $this->model( (object) $attributes );
		$model->save();

		return $model;
	}
public function first_or_create( array $attributes ) {

		$model = $this->where( $attributes )->first();

		if ( $model ) {
			return $model;
		}

		$model = new $this->model( (object) $attributes );
		$model->save();

		return $model;
	}
public function first_or_create ( array $ attributes ) { $ model = $ this -> where ( $ attributes ) -> first ( ) ; if ( $ model ) { return $ model ; } $ model = new $ this -> model ( ( object ) $ attributes ) ; $ model -> save ( ) ; return $ model ; }
Find the first model matching a given set of attributes, or construct and save a new one.

The newly constructed model follows the fillable rules for the model.

@since 2.0

@param array $attributes

@return Model
Find the first model matching a given set of attributes or construct and save a new one .