diff --git a/app/Http/Controllers/CompanyController.php b/app/Http/Controllers/CompanyController.php index e52756adba3d..a8e97c3f5216 100644 --- a/app/Http/Controllers/CompanyController.php +++ b/app/Http/Controllers/CompanyController.php @@ -22,8 +22,10 @@ use App\Http\Requests\SignupRequest; use App\Jobs\Company\CreateCompany; use App\Jobs\Company\CreateCompanyToken; use App\Jobs\RegisterNewAccount; +use App\Models\Account; use App\Models\Company; use App\Repositories\CompanyRepository; +use App\Transformers\AccountTransformer; use App\Transformers\CompanyTransformer; use App\Utils\Traits\MakesHash; use Illuminate\Foundation\Bus\DispatchesJobs; @@ -118,7 +120,11 @@ class CompanyController extends BaseController */ $company_token = CreateCompanyToken::dispatchNow($company, auth()->user()); - return $this->itemResponse($company); + //todo Need to discuss this with Hillel which is the best representation to return + //when a company is created. Do we send the entire account? Do we only send back the created CompanyUser? + $this->entity_transformer = AccountTransformer::class; + $this->entity_type = Account::class; + return $this->itemResponse($company->account); } diff --git a/app/Jobs/Company/CreateCompany.php b/app/Jobs/Company/CreateCompany.php index 573e23edc4be..67fc41512bab 100644 --- a/app/Jobs/Company/CreateCompany.php +++ b/app/Jobs/Company/CreateCompany.php @@ -51,7 +51,7 @@ class CreateCompany { $company = new Company(); - $company->name = isset($this->request['name']) ?: $this->request['first_name'] . ' ' . $this->request['last_name']; + $company->name = isset($this->request['name']) ? $this->request['name'] : $this->request['first_name'] . ' ' . $this->request['last_name']; $company->account_id = $this->account->id; $company->company_key = $this->createHash(); $company->ip = request()->ip(); diff --git a/database/migrations/2014_10_13_000000_create_users_table.php b/database/migrations/2014_10_13_000000_create_users_table.php index 2f3f6ab6cf45..aeaf10c86a7e 100644 --- a/database/migrations/2014_10_13_000000_create_users_table.php +++ b/database/migrations/2014_10_13_000000_create_users_table.php @@ -116,7 +116,7 @@ class CreateUsersTable extends Migration $table->string('utm_term')->nullable(); $table->string('utm_content')->nullable(); - $table->float('discount'); + $table->float('discount')->default(0); $table->date('discount_expires')->nullable(); $table->enum('bluevine_status', ['ignored', 'signed_up'])->nullable();