public function haveRecord($table, $attributes = [])
    {
        if (class_exists($table)) {
            $model = new $table;

            if (! $model instanceof EloquentModel) {
                throw new \RuntimeException("Class $table is not an Eloquent model");
            }

            $model->fill($attributes)->save();

            return $model;
        }

        try {
            return $this->app['db']->table($table)->insertGetId($attributes);
        } catch (\Exception $e) {
            $this->fail("Could not insert record into table '$table':\n\n" . $e->getMessage());
        }
    }
public function haveRecord($table, $attributes = [])
    {
        if (class_exists($table)) {
            $model = new $table;

            if (! $model instanceof EloquentModel) {
                throw new \RuntimeException("Class $table is not an Eloquent model");
            }

            $model->fill($attributes)->save();

            return $model;
        }

        try {
            return $this->app['db']->table($table)->insertGetId($attributes);
        } catch (\Exception $e) {
            $this->fail("Could not insert record into table '$table':\n\n" . $e->getMessage());
        }
    }
public function haveRecord ( $ table , $ attributes = [ ] ) { if ( class_exists ( $ table ) ) { $ model = new $ table ; if ( ! $ model instanceof EloquentModel ) { throw new \ RuntimeException ( "Class $table is not an Eloquent model" ) ; } $ model -> fill ( $ attributes ) -> save ( ) ; return $ model ; } try { return $ this -> app [ 'db' ] -> table ( $ table ) -> insertGetId ( $ attributes ) ; } catch ( \ Exception $ e ) { $ this -> fail ( "Could not insert record into table '$table':\n\n" . $ e -> getMessage ( ) ) ; } }
Inserts record into the database.
If you pass the name of a database table as the first argument, this method returns an integer ID.
You can also pass the class name of an Eloquent model, in that case this method returns an Eloquent model.

``` php
<?php
$user_id = $I->haveRecord('users', array('name' => 'Davert')); // returns integer
$user = $I->haveRecord('App\User', array('name' => 'Davert')); // returns Eloquent model
?>
```

@param string $table
@param array  $attributes
@return EloquentModel|int
@throws \RuntimeException
@part orm
Inserts record into the database . If you pass the name of a database table as the first argument this method returns an integer ID . You can also pass the class name of an Eloquent model in that case this method returns an Eloquent model .