mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Upload company logo to client settings
This commit is contained in:
parent
2a7f62b579
commit
b8515e26b0
@ -23,6 +23,7 @@ use App\Http\Requests\Client\UpdateClientRequest;
|
||||
use App\Jobs\Client\StoreClient;
|
||||
use App\Jobs\Client\UpdateClient;
|
||||
use App\Jobs\Entity\ActionEntity;
|
||||
use App\Jobs\Util\UploadAvatar;
|
||||
use App\Models\Client;
|
||||
use App\Models\ClientContact;
|
||||
use App\Models\Country;
|
||||
@ -282,6 +283,22 @@ class ClientController extends BaseController
|
||||
|
||||
$client = $this->client_repo->save($request->all(), $client);
|
||||
|
||||
if($request->file('company_logo'))
|
||||
{
|
||||
\Log::error('settings logo present');
|
||||
|
||||
$path = UploadAvatar::dispatchNow($request->file('company_logo'), $client->company->company_key);
|
||||
|
||||
if($path){
|
||||
|
||||
$settings = $client->settings;
|
||||
$settings->company_logo_url = $client->company->domain . $path;
|
||||
$client->settings = $settings;
|
||||
$client->save();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->itemResponse($client);
|
||||
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ class CompanyController extends BaseController
|
||||
if($path){
|
||||
|
||||
$settings = $company->settings;
|
||||
$settings->logo_url = config('ninja.site_url').$path;
|
||||
$settings->company_logo_url = $company->domain . $path;
|
||||
$company->settings = $settings;
|
||||
$company->save();
|
||||
}
|
||||
@ -428,7 +428,7 @@ class CompanyController extends BaseController
|
||||
if($path){
|
||||
|
||||
$settings = $company->settings;
|
||||
$settings->logo_url = config('ninja.site_url').$path;
|
||||
$settings->company_logo_url = $company->domain . $path;
|
||||
$company->settings = $settings;
|
||||
$company->save();
|
||||
}
|
||||
|
@ -354,7 +354,7 @@ class GroupSettingController extends BaseController
|
||||
|
||||
$group_setting = $this->group_setting_repo->save($request->all(), $group_setting);
|
||||
|
||||
return $this->itemResponse($group_setting);
|
||||
return $this->itemResponse($group_setting);
|
||||
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
* @OA\Property(property="datetime_format_id", type="string", example="15", description="____________"),
|
||||
* @OA\Property(property="financial_year_start", type="string", example="2000-01-01", description="____________"),
|
||||
* @OA\Property(property="language_id", type="string", example="1", description="____________"),
|
||||
* @OA\Property(property="company_logo_url", type="string", example="https://example.com/logo.png", description="The URL to the company Logo"),
|
||||
* @OA\Property(property="custom_label1", type="string", example="Custom Label", description="____________"),
|
||||
* @OA\Property(property="custom_label2", type="string", example="Custom Label", description="____________"),
|
||||
* @OA\Property(property="custom_label3", type="string", example="Custom Label", description="____________"),
|
||||
@ -52,4 +53,5 @@
|
||||
* @OA\Property(property="default_gateway", type="integer", example="1", description="The default payment gateway"),
|
||||
* @OA\Property(property="reset_counter_date", type="string", example="2019-01-01", description="The explicit date which is used to reset counters"),
|
||||
* )
|
||||
*/
|
||||
*/
|
||||
*
|
@ -33,6 +33,8 @@ class UpdateClientRequest extends Request
|
||||
/* Ensure we have a client name, and that all emails are unique*/
|
||||
$rules['name'] = 'required';
|
||||
|
||||
$rules['company_logo'] = 'mimes:jpeg,jpg,png,gif|max:10000';
|
||||
|
||||
$rules['industry_id'] = 'integer|nullable';
|
||||
$rules['size_id'] = 'integer|nullable';
|
||||
$rules['currency_id'] = 'integer|nullable';
|
||||
|
@ -59,6 +59,7 @@ class CreateCompany
|
||||
$company->ip = request()->ip();
|
||||
$company->settings = $settings;
|
||||
$company->db = config('database.default');
|
||||
$company->domain = isset($this->request['domain']) ? $this->request['domain'] : config('ninja.site_url');
|
||||
$company->save();
|
||||
|
||||
|
||||
|
@ -189,7 +189,7 @@ class Company extends BaseModel
|
||||
|
||||
public function getLogo()
|
||||
{
|
||||
return $this->settings->logo_url ?: null;
|
||||
return $this->settings->company_logo_url ?: null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -24,7 +24,7 @@ class ClientModelTest extends TestCase
|
||||
|
||||
$this->makeTestData();
|
||||
|
||||
if(config('ninja.testvars.travis') === false)
|
||||
if(config('ninja.testvars.travis') !== false)
|
||||
$this->markTestSkipped('Skip test for Travis');
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ class UploadLogoTest extends TestCase
|
||||
$response->assertStatus(200);
|
||||
|
||||
$acc = $response->json();
|
||||
$logo = $acc['data']['settings']['logo_url'];
|
||||
$logo = $acc['data']['settings']['company_logo_url'];
|
||||
|
||||
$logo_file = Storage::url($logo);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user