/** * Save a new model and return the instance. * * @param array $attributes * @return static */ public static function create(array $attributes = []) { $attributes['detail'] = isset($attributes['detail']) ? serialize($attributes['detail']) : null; $attributes['user_agent'] = Request::header('user-agent'); $attributes['ip_address'] = Request::ip(); $attributes['occurred_at'] = Carbon::now(); return parent::create($attributes); }
/** * Save a new model and return the instance. * * @param array $attributes * @return static */ public static function create(array $attributes = []) { DB::beginTransaction(); $account = parent::create(['email' => $attributes['email'], 'password' => bcrypt($attributes['password'])]); if (!$account->exists || !$account->user()->create(['account_id' => $account->getAttribute('id'), 'nickname' => $account->getAttribute('email')])->exists) { DB::rollBack(); } else { DB::commit(); } return $account; }
/** * @test */ public function it_should_return_entity_table_name() { $this->assertSame('entities', Entity::getTableName()); }