diff --git a/app/Http/Requests/Company/StoreCompanyRequest.php b/app/Http/Requests/Company/StoreCompanyRequest.php index 26b97578e4eb..db17aee86f28 100644 --- a/app/Http/Requests/Company/StoreCompanyRequest.php +++ b/app/Http/Requests/Company/StoreCompanyRequest.php @@ -34,6 +34,8 @@ class StoreCompanyRequest extends Request return [ 'name' => 'required', + 'logo' => 'mimes:jpeg,jpg,png,gif|max:10000', // max 10000kb + // 'documents' => 'mimes:png,ai,svg,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx', ]; } diff --git a/app/Http/Requests/Company/UpdateCompanyRequest.php b/app/Http/Requests/Company/UpdateCompanyRequest.php index edd4a4f59d72..6fd5e00a2289 100644 --- a/app/Http/Requests/Company/UpdateCompanyRequest.php +++ b/app/Http/Requests/Company/UpdateCompanyRequest.php @@ -34,7 +34,8 @@ class UpdateCompanyRequest extends Request public function rules() { return [ - // 'documents' => 'mimes:png,ai,svg,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx', + 'logo' => 'mimes:jpeg,jpg,png,gif|max:10000', // max 10000kb + 'name' => 'required', ]; } diff --git a/app/Models/Company.php b/app/Models/Company.php index 74a5b9d94939..5c1e138acd00 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -43,6 +43,7 @@ class Company extends BaseModel protected $fillable = [ 'name', + 'logo', ]; protected $appends = [ diff --git a/app/Transformers/CompanyTransformer.php b/app/Transformers/CompanyTransformer.php index 5bf1c2b1aab7..82e85ccba959 100644 --- a/app/Transformers/CompanyTransformer.php +++ b/app/Transformers/CompanyTransformer.php @@ -67,6 +67,7 @@ class CompanyTransformer extends EntityTransformer return [ 'id' => $this->encodePrimaryKey($company->id), 'name' => $company->name, + 'logo' => $company->logo, 'company_key' => $company->company_key, 'address1' => $company->address1, 'address2' => $company->address2, 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 aeaf10c86a7e..45e2ca4edcd0 100644 --- a/database/migrations/2014_10_13_000000_create_users_table.php +++ b/database/migrations/2014_10_13_000000_create_users_table.php @@ -133,6 +133,7 @@ class CreateUsersTable extends Migration $table->unsignedInteger('industry_id')->nullable(); $table->string('ip'); $table->string('company_key',100)->unique(); + $table->string('logo')->nullable(); $table->string('address1')->nullable(); $table->string('address2')->nullable(); $table->string('city')->nullable(); diff --git a/tests/Feature/CompanyTest.php b/tests/Feature/CompanyTest.php index 078224d2d639..00470e494a29 100644 --- a/tests/Feature/CompanyTest.php +++ b/tests/Feature/CompanyTest.php @@ -14,6 +14,7 @@ use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Foundation\Testing\WithFaker; use Illuminate\Http\Request; +use Illuminate\Http\UploadedFile; use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Session; use Tests\TestCase; @@ -81,7 +82,8 @@ class CompanyTest extends TestCase 'X-API-TOKEN' => $token, ])->post('/api/v1/companies/', [ - 'name' => 'A New Company' + 'name' => 'A New Company', + 'logo' => UploadedFile::fake()->image('avatar.jpg') ] ) ->assertStatus(200)->decodeResponseJson(); @@ -89,10 +91,25 @@ class CompanyTest extends TestCase $company = Company::find($this->decodePrimaryKey($response['data']['company_users'][0]['company']['id'])); + + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $token, + ])->post('/api/v1/companies/', + [ + 'name' => 'A New Company', + 'logo' => UploadedFile::fake()->create('avatar.pdf',100) + ] + ) + ->assertStatus(302); + + Log::error($company); + $token = CompanyToken::whereCompanyId($company->id)->first()->token; $company_update = [ - 'name' => 'CHANGE NAME' + 'name' => 'CHANGE NAME', + // 'logo' => UploadedFile::fake()->image('avatar.jpg') ]; $response = $this->withHeaders([ @@ -102,6 +119,7 @@ class CompanyTest extends TestCase ->assertStatus(200); + $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $token,