Finished implementing add additional company to account

This commit is contained in:
David Bomba 2019-06-26 09:44:08 +10:00
parent 07b4b81117
commit 65afb4242b
3 changed files with 9 additions and 3 deletions

View File

@ -22,8 +22,10 @@ use App\Http\Requests\SignupRequest;
use App\Jobs\Company\CreateCompany; use App\Jobs\Company\CreateCompany;
use App\Jobs\Company\CreateCompanyToken; use App\Jobs\Company\CreateCompanyToken;
use App\Jobs\RegisterNewAccount; use App\Jobs\RegisterNewAccount;
use App\Models\Account;
use App\Models\Company; use App\Models\Company;
use App\Repositories\CompanyRepository; use App\Repositories\CompanyRepository;
use App\Transformers\AccountTransformer;
use App\Transformers\CompanyTransformer; use App\Transformers\CompanyTransformer;
use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesHash;
use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Bus\DispatchesJobs;
@ -118,7 +120,11 @@ class CompanyController extends BaseController
*/ */
$company_token = CreateCompanyToken::dispatchNow($company, auth()->user()); $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);
} }

View File

@ -51,7 +51,7 @@ class CreateCompany
{ {
$company = new Company(); $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->account_id = $this->account->id;
$company->company_key = $this->createHash(); $company->company_key = $this->createHash();
$company->ip = request()->ip(); $company->ip = request()->ip();

View File

@ -116,7 +116,7 @@ class CreateUsersTable extends Migration
$table->string('utm_term')->nullable(); $table->string('utm_term')->nullable();
$table->string('utm_content')->nullable(); $table->string('utm_content')->nullable();
$table->float('discount'); $table->float('discount')->default(0);
$table->date('discount_expires')->nullable(); $table->date('discount_expires')->nullable();
$table->enum('bluevine_status', ['ignored', 'signed_up'])->nullable(); $table->enum('bluevine_status', ['ignored', 'signed_up'])->nullable();