mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
Fixes for resolve user / company
This commit is contained in:
parent
c166278b9a
commit
11a150274d
@ -453,18 +453,16 @@ class CompanyExport implements ShouldQueue
|
||||
Storage::disk(config('filesystems.default'))->put($path.$file_name, $tempStream);
|
||||
// fclose($fp);
|
||||
|
||||
nlog(Storage::disk(config('filesystems.default'))->url($path.$file_name));
|
||||
|
||||
fclose($tempStream);
|
||||
|
||||
// $nmo = new NinjaMailerObject;
|
||||
// $nmo->mailable = new DownloadBackup(Storage::disk(config('filesystems.default'))->url($path.$file_name), $this->company);
|
||||
// $nmo->to_user = $this->user;
|
||||
// $nmo->settings = $this->company->settings;
|
||||
// $nmo->company = $this->company;
|
||||
|
||||
// NinjaMailerJob::dispatch($nmo);
|
||||
$nmo = new NinjaMailerObject;
|
||||
$nmo->mailable = new DownloadBackup(Storage::disk(config('filesystems.default'))->url($path.$file_name), $this->company);
|
||||
$nmo->to_user = $this->user;
|
||||
$nmo->company = $this->company;
|
||||
$nmo->settings = $this->company->settings;
|
||||
|
||||
NinjaMailerJob::dispatch($nmo);
|
||||
|
||||
UnlinkFile::dispatch(config('filesystems.default'), $path.$file_name)->delay(now()->addHours(1));
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@ use App\Libraries\Google\Google;
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Mail\TemplateEmail;
|
||||
use App\Models\ClientContact;
|
||||
use App\Models\Company;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Payment;
|
||||
use App\Models\SystemLog;
|
||||
@ -72,6 +73,8 @@ class NinjaMailerJob implements ShouldQueue
|
||||
/*Set the correct database*/
|
||||
MultiDB::setDb($this->nmo->company->db);
|
||||
|
||||
$company = Company::where('company_key', $this->nmo->company->company_key)->first();
|
||||
|
||||
/* Set the email driver */
|
||||
$this->setMailDriver();
|
||||
|
||||
@ -86,7 +89,7 @@ class NinjaMailerJob implements ShouldQueue
|
||||
|
||||
}
|
||||
else {
|
||||
$this->nmo->mailable->replyTo($this->nmo->company->owner()->email, $this->nmo->company->owner()->present()->name());
|
||||
$this->nmo->mailable->replyTo($company->owner()->email, $company->owner()->present()->name());
|
||||
}
|
||||
|
||||
|
||||
|
@ -27,14 +27,17 @@ class DownloadBackup extends Mailable
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$company = Company::where('company_key', $this->company->company_key)->first();
|
||||
|
||||
return $this->from(config('mail.from.address'), config('mail.from.name'))
|
||||
->subject(ctrans('texts.download_backup_subject'))
|
||||
->markdown(
|
||||
'email.admin.download_files',
|
||||
[
|
||||
'url' => $this->file_path,
|
||||
'logo' => $this->company->present()->logo,
|
||||
'whitelabel' => $this->company->account->isPaid() ? true : false,
|
||||
'logo' => $company->present()->logo,
|
||||
'whitelabel' => $company->account->isPaid() ? true : false,
|
||||
'settings' => $company->settings
|
||||
]
|
||||
);
|
||||
}
|
||||
|
@ -432,12 +432,8 @@ class Company extends BaseModel
|
||||
}
|
||||
|
||||
public function owner()
|
||||
{nlog("in owner");
|
||||
$c = $this->company_users->where('is_owner', true)->first();
|
||||
|
||||
nlog($c);
|
||||
|
||||
return User::find($c->user_id);
|
||||
{
|
||||
return $this->company_users->where('is_owner', true)->first()->user;
|
||||
}
|
||||
|
||||
public function resolveRouteBinding($value, $field = null)
|
||||
|
@ -170,12 +170,10 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||
public function getCompany()
|
||||
{
|
||||
if ($this->company) {
|
||||
nlog("company Found");
|
||||
return $this->company;
|
||||
}
|
||||
|
||||
if (request()->header('X-API-TOKEN')) {
|
||||
nlog("no company - using token to resolve");
|
||||
$company_token = CompanyToken::with(['company'])->whereRaw('BINARY `token`= ?', [request()->header('X-API-TOKEN')])->first();
|
||||
|
||||
return $company_token->company;
|
||||
|
Loading…
Reference in New Issue
Block a user