mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Invoice Factory and Repo
This commit is contained in:
parent
2d5fc9e066
commit
931ea9634c
@ -11,23 +11,24 @@ class InvoiceController extends BaseController
|
|||||||
|
|
||||||
use MakesHash;
|
use MakesHash;
|
||||||
|
|
||||||
protected $entityType = Invoice::class;
|
protected $entity_type = Invoice::class;
|
||||||
|
|
||||||
protected $entityTransformer = InvoiceTransformer::class;
|
protected $entity_transformer = InvoiceTransformer::class;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var ClientRepository
|
* @var ClientRepository
|
||||||
*/
|
*/
|
||||||
protected $clientRepo;
|
protected $invoice_repo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ClientController constructor.
|
* ClientController constructor.
|
||||||
* @param ClientRepository $clientRepo
|
* @param ClientRepository $clientRepo
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct(InvoiceRespository $invoice_repo)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
|
$this->invoice_repo = $invoice_repo;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,18 +13,16 @@ class Invoice extends BaseModel
|
|||||||
'id',
|
'id',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $appends = ['invoice_id'];
|
public function company()
|
||||||
|
|
||||||
public function getRouteKeyName()
|
|
||||||
{
|
{
|
||||||
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()
|
public function invitations()
|
||||||
{
|
{
|
||||||
$this->morphMany(Invitation::class, 'inviteable');
|
$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…
x
Reference in New Issue
Block a user