mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-18 00:02:15 +00:00
store invoice profile
This commit is contained in:
40
app/Http/Controllers/Oasis/InvoiceProfileController.php
Normal file
40
app/Http/Controllers/Oasis/InvoiceProfileController.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Oasis;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\Oasis\InvoiceProfileCollection;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class InvoiceProfileController extends Controller
|
||||
{
|
||||
public function store(Request $request)
|
||||
{
|
||||
$profile = \Auth::user()
|
||||
->invoiceProfile()
|
||||
->create([
|
||||
'logo' => store_avatar($request, 'logo') ?? null,
|
||||
'stamp' => store_avatar($request, 'stamp') ?? null,
|
||||
'company' => $request->company,
|
||||
'email' => $request->email,
|
||||
'ico' => $request->ico,
|
||||
'dic' => $request->dic,
|
||||
'ic_dph' => $request->ic_dph,
|
||||
'registration_notes' => $request->registration_notes,
|
||||
'author' => $request->author,
|
||||
'address' => $request->address,
|
||||
'state' => $request->state,
|
||||
'city' => $request->city,
|
||||
'postal_code' => $request->postal_code,
|
||||
'country' => $request->country,
|
||||
'phone' => $request->phone,
|
||||
'bank' => $request->bank,
|
||||
'iban' => $request->iban,
|
||||
'swift' => $request->swift,
|
||||
]);
|
||||
|
||||
return response(
|
||||
new InvoiceProfileCollection($profile), 201
|
||||
);
|
||||
}
|
||||
}
|
||||
47
app/Http/Requests/Oasis/StoreInvoiceProfileRequest.php
Normal file
47
app/Http/Requests/Oasis/StoreInvoiceProfileRequest.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Oasis;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreInvoiceProfileRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'logo' => 'sometimes|file',
|
||||
'stamp' => 'sometimes|file',
|
||||
'company' => 'required|string',
|
||||
'email' => 'required|email',
|
||||
'ico' => 'sometimes|string|nullable',
|
||||
'dic' => 'sometimes|string|nullable',
|
||||
'ic_dph' => 'sometimes|string|nullable',
|
||||
'registration_notes' => 'sometimes|string|nullable',
|
||||
'author' => 'required|string',
|
||||
'address' => 'required|string',
|
||||
'state' => 'required|string',
|
||||
'city' => 'required|string',
|
||||
'postal_code' => 'required|string',
|
||||
'country' => 'required|string',
|
||||
'phone' => 'required|string',
|
||||
'bank' => 'required|string',
|
||||
'iban' => 'required|string',
|
||||
'swift' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
21
app/Http/Resources/Oasis/InvoiceProfileCollection.php
Normal file
21
app/Http/Resources/Oasis/InvoiceProfileCollection.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Oasis;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class InvoiceProfileCollection extends ResourceCollection
|
||||
{
|
||||
public $collects = InvoiceProfileResource::class;
|
||||
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return $this->collection;
|
||||
}
|
||||
}
|
||||
45
app/Http/Resources/Oasis/InvoiceProfileResource.php
Normal file
45
app/Http/Resources/Oasis/InvoiceProfileResource.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Oasis;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Laravel\Cashier\Cashier;
|
||||
|
||||
class InvoiceProfileResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => [
|
||||
'id' => $this->id,
|
||||
'type' => 'invoice-profile',
|
||||
'attributes' => [
|
||||
'logo' => $this->logo,
|
||||
'stamp' => $this->stamp,
|
||||
'company' => $this->company,
|
||||
'email' => $this->email,
|
||||
'ico' => $this->ico,
|
||||
'dic' => $this->dic,
|
||||
'ic_dph' => $this->ic_dph,
|
||||
'registration_notes' => $this->registration_notes,
|
||||
'author' => $this->author,
|
||||
'address' => $this->address,
|
||||
'state' => $this->state,
|
||||
'city' => $this->city,
|
||||
'postal_code' => $this->postal_code,
|
||||
'country' => $this->country,
|
||||
'phone' => $this->phone,
|
||||
'bank' => $this->bank,
|
||||
'iban' => $this->iban,
|
||||
'swift' => $this->swift,
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user