1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-05 18:52:44 +01:00

Add ability to upload company logo

This commit is contained in:
David Bomba 2019-06-26 13:25:14 +10:00
parent e51c545f1a
commit 879d87ea60
6 changed files with 27 additions and 3 deletions

View File

@ -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',
];
}

View File

@ -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',
];
}

View File

@ -43,6 +43,7 @@ class Company extends BaseModel
protected $fillable = [
'name',
'logo',
];
protected $appends = [

View File

@ -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,

View File

@ -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();

View File

@ -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,