mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-05 03:34:36 -04:00
Add ability to upload company logo
This commit is contained in:
parent
e51c545f1a
commit
879d87ea60
@ -34,6 +34,8 @@ class StoreCompanyRequest extends Request
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
'name' => 'required',
|
'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',
|
// 'documents' => 'mimes:png,ai,svg,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,8 @@ class UpdateCompanyRequest extends Request
|
|||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
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',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@ class Company extends BaseModel
|
|||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'name',
|
'name',
|
||||||
|
'logo',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $appends = [
|
protected $appends = [
|
||||||
|
@ -67,6 +67,7 @@ class CompanyTransformer extends EntityTransformer
|
|||||||
return [
|
return [
|
||||||
'id' => $this->encodePrimaryKey($company->id),
|
'id' => $this->encodePrimaryKey($company->id),
|
||||||
'name' => $company->name,
|
'name' => $company->name,
|
||||||
|
'logo' => $company->logo,
|
||||||
'company_key' => $company->company_key,
|
'company_key' => $company->company_key,
|
||||||
'address1' => $company->address1,
|
'address1' => $company->address1,
|
||||||
'address2' => $company->address2,
|
'address2' => $company->address2,
|
||||||
|
@ -133,6 +133,7 @@ class CreateUsersTable extends Migration
|
|||||||
$table->unsignedInteger('industry_id')->nullable();
|
$table->unsignedInteger('industry_id')->nullable();
|
||||||
$table->string('ip');
|
$table->string('ip');
|
||||||
$table->string('company_key',100)->unique();
|
$table->string('company_key',100)->unique();
|
||||||
|
$table->string('logo')->nullable();
|
||||||
$table->string('address1')->nullable();
|
$table->string('address1')->nullable();
|
||||||
$table->string('address2')->nullable();
|
$table->string('address2')->nullable();
|
||||||
$table->string('city')->nullable();
|
$table->string('city')->nullable();
|
||||||
|
@ -14,6 +14,7 @@ use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
use Illuminate\Foundation\Testing\WithFaker;
|
use Illuminate\Foundation\Testing\WithFaker;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\UploadedFile;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\Support\Facades\Session;
|
use Illuminate\Support\Facades\Session;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
@ -81,7 +82,8 @@ class CompanyTest extends TestCase
|
|||||||
'X-API-TOKEN' => $token,
|
'X-API-TOKEN' => $token,
|
||||||
])->post('/api/v1/companies/',
|
])->post('/api/v1/companies/',
|
||||||
[
|
[
|
||||||
'name' => 'A New Company'
|
'name' => 'A New Company',
|
||||||
|
'logo' => UploadedFile::fake()->image('avatar.jpg')
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
->assertStatus(200)->decodeResponseJson();
|
->assertStatus(200)->decodeResponseJson();
|
||||||
@ -89,10 +91,25 @@ class CompanyTest extends TestCase
|
|||||||
|
|
||||||
$company = Company::find($this->decodePrimaryKey($response['data']['company_users'][0]['company']['id']));
|
$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;
|
$token = CompanyToken::whereCompanyId($company->id)->first()->token;
|
||||||
|
|
||||||
$company_update = [
|
$company_update = [
|
||||||
'name' => 'CHANGE NAME'
|
'name' => 'CHANGE NAME',
|
||||||
|
// 'logo' => UploadedFile::fake()->image('avatar.jpg')
|
||||||
];
|
];
|
||||||
|
|
||||||
$response = $this->withHeaders([
|
$response = $this->withHeaders([
|
||||||
@ -102,6 +119,7 @@ class CompanyTest extends TestCase
|
|||||||
->assertStatus(200);
|
->assertStatus(200);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$response = $this->withHeaders([
|
$response = $this->withHeaders([
|
||||||
'X-API-SECRET' => config('ninja.api_secret'),
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
'X-API-TOKEN' => $token,
|
'X-API-TOKEN' => $token,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user