mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-09 20:52:56 +01:00
Invoice Factory and Repo
This commit is contained in:
parent
2d5fc9e066
commit
931ea9634c
@ -11,23 +11,24 @@ class InvoiceController extends BaseController
|
||||
|
||||
use MakesHash;
|
||||
|
||||
protected $entityType = Invoice::class;
|
||||
protected $entity_type = Invoice::class;
|
||||
|
||||
protected $entityTransformer = InvoiceTransformer::class;
|
||||
protected $entity_transformer = InvoiceTransformer::class;
|
||||
|
||||
/**
|
||||
* @var ClientRepository
|
||||
*/
|
||||
protected $clientRepo;
|
||||
protected $invoice_repo;
|
||||
|
||||
/**
|
||||
* ClientController constructor.
|
||||
* @param ClientRepository $clientRepo
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(InvoiceRespository $invoice_repo)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->invoice_repo = $invoice_repo;
|
||||
|
||||
}
|
||||
|
||||
|
@ -13,18 +13,16 @@ class Invoice extends BaseModel
|
||||
'id',
|
||||
];
|
||||
|
||||
protected $appends = ['invoice_id'];
|
||||
|
||||
public function getRouteKeyName()
|
||||
public function company()
|
||||
{
|
||||
return 'invoice_id';
|
||||
return $this->belongsTo(Company::class);
|
||||
}
|
||||
|
||||
public function getInvoiceIdAttribute()
|
||||
public function user()
|
||||
{
|
||||
return $this->encodePrimaryKey($this->id);
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
|
||||
public function invitations()
|
||||
{
|
||||
$this->morphMany(Invitation::class, 'inviteable');
|
||||
|
27
app/Repositories/InvoiceRepository.php
Normal file
27
app/Repositories/InvoiceRepository.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Models\Invoice;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class InvoiceRepository extends BaseRepository
|
||||
{
|
||||
|
||||
public function getClassName()
|
||||
{
|
||||
return Invoice::class;
|
||||
}
|
||||
|
||||
public function save(Request $request, Invoice $invoice) : ?Invoice
|
||||
{
|
||||
$invoice->fill($request->input());
|
||||
$invoice->save();
|
||||
|
||||
return $invoice;
|
||||
}
|
||||
|
||||
}
|
9
database/factories/InvoiceFactory.php
Normal file
9
database/factories/InvoiceFactory.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(Model::class, function (Faker $faker) {
|
||||
return [
|
||||
//
|
||||
];
|
||||
});
|
Loading…
Reference in New Issue
Block a user