PHP code example of emizoripx / clientfel
1. Go to this page and download the library: Download emizoripx/clientfel library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
emizoripx / clientfel example snippets
use EmizorIpx\ClientFel\routes\Credentials;
...
Credentials::routes();
namespace App\Repositories;
//class BaseRepository{
...
# insert here the method that send to fel
$model->createInvoiceFel();
# before return
// return $model->fresh();
// public function rules()
// {
// return [
// //'email' => ' => 'string:max:100',
// 'password' => 'acy_policy' => ''
// ];
// }
namespace App\Http\Controllers;
use EmizorIpx\ClientFel\Utils\Presenter;
protected function response($response)
{
$index = request()->input('index') ?: $this->forced_index;
if ($index == 'none') {
...
} else {
...
$response = Presenter::appendFelData($response, auth()->user()->getCompany()->id);
...
}
...
return ...
}
namespace App\Http\Requests\Shop;
...
use EmizorIpx\ClientFel\Http\ValidationRules\Invoice\InvoiceRules;
...
class StoreShopInvoiceRequest extends Request{
public function rules()
{
...
$rules = array_merge($rules, InvoiceRules::additionalInvoiceRules());
return $rules;
}
...
}
namespace App\Http\Requests\Shop;
...
use EmizorIpx\ClientFel\Http\ValidationRules\Invoice\ClientRules;
...
class StoreShopClientRequest extends Request{
public function rules()
{
...
$rules = array_merge($rules, ClientRules::additionalClientRules());
return $rules;
}
...
}
namespace App\Http\Controllers\Shop;
...
use EmizorIpx\ClientFel\Repository\FelInvoiceRequestRepository;
...
class InvoiceController extends BaseController{
...
public function store(StoreShopInvoiceRequest $request)
{
...
$client = Client::find($request->input('client_id'));
...
#Add
$inputData = FelInvoiceRequestRepository::completeDataRequest($request->all(), $company->id);
$request->replace($inputData);
$invoice = $this->invoice_repo->save($request->all(), InvoiceFactory::create($company->id, $company->owner()->id));
...
return $this->itemResponse($invoice);
}
}
namespace App\Http\Controllers\Shop;
...
use EmizorIpx\ClientFel\Repository\FelClientRepository;
...
class ClientController extends BaseController{
...
public function store(StoreShopClientRequest $request)
{
...
#Add
$inputData = FelClientRepository::completeDataRequest($request->all());
$request->replace($inputData);
$invoice = $this->invoice_repo->save($request->all(), ClientFactory::create($company->id, $company->owner()->id));
...
return $this->itemResponse($invoice);
}
}
namespace App\Models;
...
use EmizorIpx\ClientFel\Traits\InvoiceFelEmitTrait;
...
class Invoice extends BaseModel
{
...
use InvoiceFelEmitTrait;
...
}
namespace App\Http\Controllers\Shop;
class InvoiceController extends BaseController
{
public function store(StoreShopInvoiceRequest $request)
{
...
$invoice = $invoice->service()->triggeredActions($request)->save();
$invoice->emit();
...
return $this->itemResponse($invoice);
}
}
use Illuminate\Support\Facades\Route;
Route::group(['middleware' => ['company_key_db', 'locale'], 'prefix' => 'api/v1'], function () {
...
Route::middleware(['check_settings'])->group(function () {
Route::post('shop/invoices', 'Shop\InvoiceController@store');
});
...
});