1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 08:21:34 +02:00

Change document->path to ->url

This commit is contained in:
David Bomba 2020-06-22 15:52:20 +10:00
parent 4bb4c9fbe7
commit 2fadadf5d4
9 changed files with 19 additions and 9 deletions

View File

@ -265,7 +265,9 @@ class BaseController extends Controller
'company.payments.paymentables',
'company.quotes.invitations.contact',
'company.quotes.invitations.company',
'company.quotes.documents',
'company.credits.invitations.company',
'company.credits.documents',
'company.payment_terms.company',
//'company.credits.invitations.contact',
//'company.credits.invitations.company',

View File

@ -88,7 +88,7 @@ class UploadFile implements ShouldQueue
$document = new Document();
$document->user_id = $this->user->id;
$document->company_id = $this->company->id;
$document->path = $instance;
$document->url = $instance;
$document->name = $this->file->getClientOriginalName();
$document->type = $this->file->extension();
$document->disk = $this->disk;

View File

@ -170,6 +170,12 @@ class Credit extends BaseModel
return $this->morphToMany(Payment::class, 'paymentable');
}
public function documents()
{
return $this->morphMany(Document::class, 'documentable');
}
/**
* Access the invoice calculator object
*

View File

@ -100,7 +100,7 @@ class Document extends BaseModel
public function generateUrl($absolute = false)
{
$url = Storage::disk($this->disk)->url($this->path);
$url = Storage::disk($this->disk)->url($this->url);
if ($url && $absolute) {
return url($url);

View File

@ -24,13 +24,14 @@ class CreditTransformer extends EntityTransformer
protected $defaultIncludes = [
'invitations',
'documents',
];
protected $availableIncludes = [
'invitations',
// 'payments',
// 'client',
// 'documents',
'documents',
];
public function includeInvitations(Credit $credit)

View File

@ -37,7 +37,7 @@ class DocumentTransformer extends EntityTransformer
'assigned_user_id' => $this->encodePrimaryKey($document->assigned_user_id),
'project_id' => $this->encodePrimaryKey($document->project_id),
'vendor_id' => $this->encodePrimaryKey($document->vendor_id),
'path' => (string) $document->path ?: '',
'url' => (string) $document->url ?: '',
'preview' => (string) $document->preview ?: '',
'name' => (string) $document->name,
'type' => (string) $document->type,

View File

@ -22,13 +22,14 @@ class QuoteTransformer extends EntityTransformer
protected $defaultIncludes = [
'invitations',
'documents',
];
protected $availableIncludes = [
'invitations',
'documents',
// 'payments',
// 'client',
// 'documents',
];
public function includeInvitations(Quote $quote)

View File

@ -222,7 +222,7 @@ class CreateUsersTable extends Migration
$table->unsignedInteger('company_id')->index();
$table->unsignedInteger('project_id')->nullable();
$table->unsignedInteger('vendor_id')->nullable();
$table->string('path')->nullable();
$table->string('url')->nullable();
$table->string('preview')->nullable();
$table->string('name')->nullable();
$table->string('type')->nullable();

View File

@ -47,7 +47,7 @@ class CompanyDocumentsTest extends TestCase
$this->assertNotNull($document);
$this->assertTrue(Storage::exists($document->path));
$this->assertTrue(Storage::exists($document->url));
$this->assertGreaterThan($original_count, Document::whereCompanyId($this->company->id)->count());
@ -55,6 +55,6 @@ class CompanyDocumentsTest extends TestCase
$this->assertEquals(0, Document::whereCompanyId($this->company->id)->count());
$this->assertFalse(Storage::exists($document->path));
$this->assertFalse(Storage::exists($document->url));
}
}