diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index bedd098b6cf0..aab2be9b7931 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -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; } diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index c683c92e0f26..af2e4c449451 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -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'); diff --git a/app/Repositories/InvoiceRepository.php b/app/Repositories/InvoiceRepository.php new file mode 100644 index 000000000000..7823c72ff0d4 --- /dev/null +++ b/app/Repositories/InvoiceRepository.php @@ -0,0 +1,27 @@ +fill($request->input()); + $invoice->save(); + + return $invoice; + } + +} \ No newline at end of file diff --git a/database/factories/InvoiceFactory.php b/database/factories/InvoiceFactory.php new file mode 100644 index 000000000000..65e422147c56 --- /dev/null +++ b/database/factories/InvoiceFactory.php @@ -0,0 +1,9 @@ +define(Model::class, function (Faker $faker) { + return [ + // + ]; +});