mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Documents
This commit is contained in:
parent
63f8700db1
commit
f958effb81
@ -89,6 +89,11 @@ class Client extends BaseModel
|
||||
return ClientSettings::buildClientSettings($this->company->settings, $this->settings);
|
||||
}
|
||||
|
||||
public function documents()
|
||||
{
|
||||
return $this->morphMany(Document::class, 'documentable');
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
14
app/Models/Document.php
Normal file
14
app/Models/Document.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Document extends BaseModel
|
||||
{
|
||||
public function documentable()
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
}
|
@ -24,4 +24,9 @@ class Expense extends BaseModel
|
||||
{
|
||||
return $this->encodePrimaryKey($this->id);
|
||||
}
|
||||
|
||||
public function documents()
|
||||
{
|
||||
return $this->morphMany(Document::class, 'documentable');
|
||||
}
|
||||
}
|
||||
|
@ -53,4 +53,9 @@ class Invoice extends BaseModel
|
||||
{
|
||||
return $this->belongsTo(Client::class);
|
||||
}
|
||||
|
||||
public function documents()
|
||||
{
|
||||
return $this->morphMany(Document::class, 'documentable');
|
||||
}
|
||||
}
|
||||
|
@ -24,4 +24,9 @@ class Payment extends BaseModel
|
||||
{
|
||||
return $this->encodePrimaryKey($this->id);
|
||||
}
|
||||
|
||||
public function documents()
|
||||
{
|
||||
return $this->morphMany(Document::class, 'documentable');
|
||||
}
|
||||
}
|
||||
|
@ -31,5 +31,10 @@ class Product extends BaseModel
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function documents()
|
||||
{
|
||||
return $this->morphMany(Document::class, 'documentable');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -25,5 +25,9 @@ class Proposal extends BaseModel
|
||||
return $this->encodePrimaryKey($this->id);
|
||||
}
|
||||
|
||||
public function documents()
|
||||
{
|
||||
return $this->morphMany(Document::class, 'documentable');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -33,4 +33,9 @@ class Quote extends BaseModel
|
||||
return $this->hasMany(QuoteInvitation::class);
|
||||
}
|
||||
|
||||
public function documents()
|
||||
{
|
||||
return $this->morphMany(Document::class, 'documentable');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,4 +25,9 @@ class Task extends BaseModel
|
||||
return $this->encodePrimaryKey($this->id);
|
||||
}
|
||||
|
||||
public function documents()
|
||||
{
|
||||
return $this->morphMany(Document::class, 'documentable');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -258,4 +258,8 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||
|
||||
}
|
||||
|
||||
public function documents()
|
||||
{
|
||||
return $this->morphMany(Document::class, 'documentable');
|
||||
}
|
||||
}
|
||||
|
@ -186,8 +186,29 @@ class CreateUsersTable extends Migration
|
||||
|
||||
});
|
||||
|
||||
Schema::create('documents', function (Blueprint $table){
|
||||
$table->increments('id');
|
||||
$table->unsignedInteger('user_id');
|
||||
$table->unsignedInteger('company_id')->index();
|
||||
$table->string('path');
|
||||
$table->string('preview');
|
||||
$table->string('name');
|
||||
$table->string('type');
|
||||
$table->string('disk');
|
||||
$table->string('hash', 100);
|
||||
$table->unsignedInteger('size')->nullable();
|
||||
$table->unsignedInteger('width')->nullable();
|
||||
$table->unsignedInteger('height')->nullable();
|
||||
$table->boolean('is_default')->default(0);
|
||||
|
||||
|
||||
$table->unsignedInteger('documentable_id');
|
||||
$table->string('documentable_type');
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('company_id')->references('id')->on('companies')->onDelete('cascade');
|
||||
|
||||
});
|
||||
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
|
||||
$table->increments('id');
|
||||
|
Loading…
x
Reference in New Issue
Block a user