v2 first commit

This commit is contained in:
denisdulici
2019-11-16 10:21:14 +03:00
parent 5b23e9c2c4
commit 6d50fa8442
3075 changed files with 3451681 additions and 65594 deletions

View File

@ -1,231 +0,0 @@
<?php
namespace App\Http\Controllers\Modals;
use App\Http\Controllers\Controller;
use App\Http\Requests\Expense\BillPayment as Request;
use App\Models\Expense\Bill;
use App\Models\Banking\Account;
use App\Models\Expense\BillPayment;
use App\Models\Expense\BillHistory;
use App\Models\Setting\Currency;
use App\Utilities\Modules;
use App\Traits\Uploads;
use App\Jobs\Expense\CreateBillPayment;
class BillPayments extends Controller
{
use Uploads;
/**
* Instantiate a new controller instance.
*/
public function __construct()
{
// Add CRUD permission check
$this->middleware('permission:create-expenses-bills')->only(['create', 'store', 'duplicate', 'import']);
$this->middleware('permission:read-expenses-bills')->only(['index', 'show', 'edit', 'export']);
$this->middleware('permission:update-expenses-bills')->only(['update', 'enable', 'disable']);
$this->middleware('permission:delete-expenses-bills')->only('destroy');
}
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create(Bill $bill)
{
$accounts = Account::enabled()->orderBy('name')->pluck('name', 'id');
$currencies = Currency::enabled()->orderBy('name')->pluck('name', 'code')->toArray();
$currency = Currency::where('code', $bill->currency_code)->first();
$payment_methods = Modules::getPaymentMethods();
$paid = $this->getPaid($bill);
// Get Bill Totals
foreach ($bill->totals as $bill_total) {
$bill->{$bill_total->code} = $bill_total->amount;
}
$total = money($bill->total, $currency->code, true)->format();
$bill->grand_total = money($total, $currency->code)->getAmount();
if (!empty($paid)) {
$bill->grand_total = round($bill->total - $paid, $currency->precision) ;
}
$rand = rand();
$html = view('modals.bills.payment', compact('bill', 'accounts', 'currencies', 'currency', 'payment_methods', 'rand'))->render();
return response()->json([
'success' => true,
'error' => false,
'message' => 'null',
'html' => $html,
]);
}
/**
* Store a newly created resource in storage.
*
* @param Request $request
*
* @return Response
*/
public function store(Bill $bill, Request $request)
{
// Get currency object
$currencies = Currency::enabled()->pluck('rate', 'code')->toArray();
$currency = Currency::where('code', $request['currency_code'])->first();
$request['currency_code'] = $currency->code;
$request['currency_rate'] = $currency->rate;
$total_amount = $bill->amount;
$default_amount = (double) $request['amount'];
if ($bill->currency_code == $request['currency_code']) {
$amount = $default_amount;
} else {
$default_amount_model = new BillPayment();
$default_amount_model->default_currency_code = $bill->currency_code;
$default_amount_model->amount = $default_amount;
$default_amount_model->currency_code = $request['currency_code'];
$default_amount_model->currency_rate = $currencies[$request['currency_code']];
$default_amount = (double) $default_amount_model->getDivideConvertedAmount();
$convert_amount = new BillPayment();
$convert_amount->default_currency_code = $request['currency_code'];
$convert_amount->amount = $default_amount;
$convert_amount->currency_code = $bill->currency_code;
$convert_amount->currency_rate = $currencies[$bill->currency_code];
$amount = (double) $convert_amount->getDynamicConvertedAmount();
}
if ($bill->payments()->count()) {
$total_amount -= $this->getPaid($bill);
}
// For amount cover integer
$multiplier = 1;
for ($i = 0; $i < $currency->precision; $i++) {
$multiplier *= 10;
}
$amount_check = (int) ($amount * $multiplier);
$total_amount_check = (int) (round($total_amount, $currency->precision) * $multiplier);
if ($amount_check > $total_amount_check) {
$error_amount = $total_amount;
if ($bill->currency_code != $request['currency_code']) {
$error_amount_model = new BillPayment();
$error_amount_model->default_currency_code = $request['currency_code'];
$error_amount_model->amount = $error_amount;
$error_amount_model->currency_code = $bill->currency_code;
$error_amount_model->currency_rate = $currencies[$bill->currency_code];
$error_amount = (double) $error_amount_model->getDivideConvertedAmount();
$convert_amount = new BillPayment();
$convert_amount->default_currency_code = $bill->currency_code;
$convert_amount->amount = $error_amount;
$convert_amount->currency_code = $request['currency_code'];
$convert_amount->currency_rate = $currencies[$request['currency_code']];
$error_amount = (double) $convert_amount->getDynamicConvertedAmount();
}
$message = trans('messages.error.over_payment', ['amount' => money($error_amount, $request['currency_code'], true)]);
return response()->json([
'success' => false,
'error' => true,
'data' => [
'amount' => $error_amount
],
'message' => $message,
'html' => 'null',
]);
} elseif ($amount_check == $total_amount_check) {
$bill->bill_status_code = 'paid';
} else {
$bill->bill_status_code = 'partial';
}
$bill->save();
$bill_payment = dispatch(new CreateBillPayment($request, $bill));
// Upload attachment
if ($request->file('attachment')) {
$media = $this->getMedia($request->file('attachment'), 'bills');
$bill_payment->attachMedia($media, 'attachment');
}
$message = trans('messages.success.added', ['type' => trans_choice('general.payments', 1)]);
return response()->json([
'success' => true,
'error' => false,
'data' => $bill_payment,
'message' => $message,
'html' => 'null',
]);
}
protected function getPaid($bill)
{
$paid = 0;
// Get Bill Payments
if ($bill->payments->count()) {
$_currencies = Currency::enabled()->pluck('rate', 'code')->toArray();
foreach ($bill->payments as $item) {
$default_amount = (double) $item->amount;
if ($bill->currency_code == $item->currency_code) {
$amount = $default_amount;
} else {
$default_amount_model = new BillPayment();
$default_amount_model->default_currency_code = $bill->currency_code;
$default_amount_model->amount = $default_amount;
$default_amount_model->currency_code = $item->currency_code;
$default_amount_model->currency_rate = $_currencies[$item->currency_code];
$default_amount = (double) $default_amount_model->getDivideConvertedAmount();
$convert_amount = new BillPayment();
$convert_amount->default_currency_code = $item->currency_code;
$convert_amount->amount = $default_amount;
$convert_amount->currency_code = $bill->currency_code;
$convert_amount->currency_rate = $_currencies[$bill->currency_code];
$amount = (double) $convert_amount->getDynamicConvertedAmount();
}
$paid += $amount;
}
}
return $paid;
}
}

View File

@ -0,0 +1,147 @@
<?php
namespace App\Http\Controllers\Modals;
use App\Abstracts\Http\Controller;
use App\Http\Requests\Banking\Transaction as Request;
use App\Jobs\Banking\CreateDocumentTransaction;
use App\Models\Banking\Account;
use App\Models\Banking\Transaction;
use App\Models\Expense\Bill;
use App\Models\Setting\Currency;
use App\Utilities\Modules;
use App\Traits\Uploads;
class BillTransactions extends Controller
{
use Uploads;
/**
* Instantiate a new controller instance.
*/
public function __construct()
{
// Add CRUD permission check
$this->middleware('permission:create-expenses-bills')->only(['create', 'store', 'duplicate', 'import']);
$this->middleware('permission:read-expenses-bills')->only(['index', 'show', 'edit', 'export']);
$this->middleware('permission:update-expenses-bills')->only(['update', 'enable', 'disable']);
$this->middleware('permission:delete-expenses-bills')->only('destroy');
}
/**
* Show the form for creating a new resource.
*
* @param Bill $bill
*
* @return Response
*/
public function create(Bill $bill)
{
$accounts = Account::enabled()->orderBy('name')->pluck('name', 'id');
$currencies = Currency::enabled()->orderBy('name')->pluck('name', 'code')->toArray();
$currency = Currency::where('code', $bill->currency_code)->first();
$payment_methods = Modules::getPaymentMethods();
$paid = $this->getPaidAmount($bill);
// Get Bill Totals
foreach ($bill->totals as $bill_total) {
$bill->{$bill_total->code} = $bill_total->amount;
}
$total = money($bill->total, $currency->code, true)->format();
$bill->grand_total = money($total, $currency->code)->getAmount();
if (!empty($paid)) {
$bill->grand_total = round($bill->total - $paid, $currency->precision) ;
}
$rand = rand();
$html = view('modals.bills.payment', compact('bill', 'accounts', 'currencies', 'currency', 'payment_methods', 'rand'))->render();
return response()->json([
'success' => true,
'error' => false,
'message' => 'null',
'html' => $html,
]);
}
/**
* Store a newly created resource in storage.
*
* @param Bill $bill
* @param Request $request
*
* @return Response
*/
public function store(Bill $bill, Request $request)
{
try {
$transaction = $this->dispatch(new CreateDocumentTransaction($bill, $request));
$message = trans('messages.success.added', ['type' => trans_choice('general.payments', 1)]);
$response = [
'success' => true,
'error' => false,
'message' => $message,
'data' => $transaction,
];
} catch(\Exception $e) {
$response = [
'success' => false,
'error' => true,
'message' => $e->getMessage(),
'data' => 'null',
];
}
return response()->json($response);
}
protected function getPaidAmount($bill)
{
$paid = 0;
// Get Bill Payments
if (!$bill->payments->count()) {
return $paid;
}
$currencies = Currency::enabled()->pluck('rate', 'code')->toArray();
foreach ($bill->payments as $item) {
$default_amount = (double) $item->amount;
if ($bill->currency_code == $item->currency_code) {
$amount = $default_amount;
} else {
$default_amount_model = new Transaction();
$default_amount_model->default_currency_code = $bill->currency_code;
$default_amount_model->amount = $default_amount;
$default_amount_model->currency_code = $item->currency_code;
$default_amount_model->currency_rate = $currencies[$item->currency_code];
$default_amount = (double) $default_amount_model->getDivideConvertedAmount();
$convert_amount_model = new Transaction();
$convert_amount_model->default_currency_code = $item->currency_code;
$convert_amount_model->amount = $default_amount;
$convert_amount_model->currency_code = $bill->currency_code;
$convert_amount_model->currency_rate = $currencies[$bill->currency_code];
$amount = (double) $convert_amount_model->getAmountConvertedFromCustomDefault();
}
$paid += $amount;
}
return $paid;
}
}

View File

@ -2,7 +2,7 @@
namespace App\Http\Controllers\Modals;
use App\Http\Controllers\Controller;
use App\Abstracts\Http\Controller;
use App\Http\Requests\Setting\Category as Request;
use Illuminate\Http\Request as CRequest;
use App\Models\Setting\Category;

View File

@ -2,20 +2,10 @@
namespace App\Http\Controllers\Modals;
use App\Http\Controllers\Controller;
use App\Http\Requests\Income\Customer as Request;
use App\Models\Auth\User;
use App\Models\Income\Customer;
use App\Models\Income\Invoice;
use App\Models\Income\Revenue;
use App\Abstracts\Http\Controller;
use App\Http\Requests\Common\Contact as Request;
use App\Models\Common\Contact;
use App\Models\Setting\Currency;
use App\Utilities\Import;
use App\Utilities\ImportFile;
use Date;
use Illuminate\Http\Request as FRequest;
use Illuminate\Pagination\Paginator;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
class Customers extends Controller
{
@ -38,17 +28,17 @@ class Customers extends Controller
*/
public function create()
{
$currencies = Currency::enabled()->pluck('name', 'code');
$currencies = Currency::enabled()->orderBy('name')->pluck('name', 'code')->toArray();
$customer_selector = false;
$contact_selector = false;
if (request()->has('customer_selector')) {
$customer_selector = request()->get('customer_selector');
if (request()->has('contact_selector')) {
$contact_selector = request()->get('contact_selector');
}
$rand = rand();
$html = view('modals.customers.create', compact('currencies', 'customer_selector', 'rand'))->render();
$html = view('modals.customers.create', compact('currencies', 'contact_selector', 'rand'))->render();
return response()->json([
'success' => true,
@ -69,7 +59,7 @@ class Customers extends Controller
{
$request['enabled'] = 1;
$customer = Customer::create($request->all());
$customer = Contact::create($request->all());
$message = trans('messages.success.added', ['type' => trans_choice('general.customers', 1)]);

View File

@ -1,231 +0,0 @@
<?php
namespace App\Http\Controllers\Modals;
use App\Http\Controllers\Controller;
use App\Http\Requests\Income\InvoicePayment as Request;
use App\Models\Income\Invoice;
use App\Models\Banking\Account;
use App\Models\Income\InvoicePayment;
use App\Models\Income\InvoiceHistory;
use App\Models\Setting\Currency;
use App\Utilities\Modules;
use App\Traits\Uploads;
use App\Jobs\Income\CreateInvoicePayment;
class InvoicePayments extends Controller
{
use Uploads;
/**
* Instantiate a new controller instance.
*/
public function __construct()
{
// Add CRUD permission check
$this->middleware('permission:create-incomes-invoices')->only(['create', 'store', 'duplicate', 'import']);
$this->middleware('permission:read-incomes-invoices')->only(['index', 'show', 'edit', 'export']);
$this->middleware('permission:update-incomes-invoices')->only(['update', 'enable', 'disable']);
$this->middleware('permission:delete-incomes-invoices')->only('destroy');
}
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create(Invoice $invoice)
{
$accounts = Account::enabled()->orderBy('name')->pluck('name', 'id');
$currencies = Currency::enabled()->orderBy('name')->pluck('name', 'code')->toArray();
$currency = Currency::where('code', $invoice->currency_code)->first();
$payment_methods = Modules::getPaymentMethods();
$paid = $this->getPaid($invoice);
// Get Invoice Totals
foreach ($invoice->totals as $invoice_total) {
$invoice->{$invoice_total->code} = $invoice_total->amount;
}
$total = money($invoice->total, $currency->code, true)->format();
$invoice->grand_total = money($total, $currency->code)->getAmount();
if (!empty($paid)) {
$invoice->grand_total = round($invoice->total - $paid, $currency->precision) ;
}
$rand = rand();
$html = view('modals.invoices.payment', compact('invoice', 'accounts', 'currencies', 'currency', 'payment_methods', 'rand'))->render();
return response()->json([
'success' => true,
'error' => false,
'message' => 'null',
'html' => $html,
]);
}
/**
* Store a newly created resource in storage.
*
* @param Request $request
*
* @return Response
*/
public function store(Invoice $invoice, Request $request)
{
// Get currency object
$currencies = Currency::enabled()->pluck('rate', 'code')->toArray();
$currency = Currency::where('code', $request['currency_code'])->first();
$request['currency_code'] = $currency->code;
$request['currency_rate'] = $currency->rate;
$total_amount = $invoice->amount;
$default_amount = (double) $request['amount'];
if ($invoice->currency_code == $request['currency_code']) {
$amount = $default_amount;
} else {
$default_amount_model = new InvoicePayment();
$default_amount_model->default_currency_code = $invoice->currency_code;
$default_amount_model->amount = $default_amount;
$default_amount_model->currency_code = $request['currency_code'];
$default_amount_model->currency_rate = $currencies[$request['currency_code']];
$default_amount = (double) $default_amount_model->getDivideConvertedAmount();
$convert_amount = new InvoicePayment();
$convert_amount->default_currency_code = $request['currency_code'];
$convert_amount->amount = $default_amount;
$convert_amount->currency_code = $invoice->currency_code;
$convert_amount->currency_rate = $currencies[$invoice->currency_code];
$amount = (double) $convert_amount->getDynamicConvertedAmount();
}
if ($invoice->payments()->count()) {
$total_amount -= $this->getPaid($invoice);
}
// For amount cover integer
$multiplier = 1;
for ($i = 0; $i < $currency->precision; $i++) {
$multiplier *= 10;
}
$amount_check = (int) ($amount * $multiplier);
$total_amount_check = (int) (round($total_amount, $currency->precision) * $multiplier);
if ($amount_check > $total_amount_check) {
$error_amount = $total_amount;
if ($invoice->currency_code != $request['currency_code']) {
$error_amount_model = new InvoicePayment();
$error_amount_model->default_currency_code = $request['currency_code'];
$error_amount_model->amount = $error_amount;
$error_amount_model->currency_code = $invoice->currency_code;
$error_amount_model->currency_rate = $currencies[$invoice->currency_code];
$error_amount = (double) $error_amount_model->getDivideConvertedAmount();
$convert_amount = new InvoicePayment();
$convert_amount->default_currency_code = $invoice->currency_code;
$convert_amount->amount = $error_amount;
$convert_amount->currency_code = $request['currency_code'];
$convert_amount->currency_rate = $currencies[$request['currency_code']];
$error_amount = (double) $convert_amount->getDynamicConvertedAmount();
}
$message = trans('messages.error.over_payment', ['amount' => money($error_amount, $request['currency_code'], true)]);
return response()->json([
'success' => false,
'error' => true,
'data' => [
'amount' => $error_amount
],
'message' => $message,
'html' => 'null',
]);
} elseif ($amount_check == $total_amount_check) {
$invoice->invoice_status_code = 'paid';
} else {
$invoice->invoice_status_code = 'partial';
}
$invoice->save();
$invoice_payment = dispatch(new CreateInvoicePayment($request, $invoice));
// Upload attachment
if ($request->file('attachment')) {
$media = $this->getMedia($request->file('attachment'), 'invoices');
$invoice_payment->attachMedia($media, 'attachment');
}
$message = trans('messages.success.added', ['type' => trans_choice('general.payments', 1)]);
return response()->json([
'success' => true,
'error' => false,
'data' => $invoice_payment,
'message' => $message,
'html' => 'null',
]);
}
protected function getPaid($invoice)
{
$paid = 0;
// Get Invoice Payments
if ($invoice->payments->count()) {
$_currencies = Currency::enabled()->pluck('rate', 'code')->toArray();
foreach ($invoice->payments as $item) {
$default_amount = $item->amount;
if ($invoice->currency_code == $item->currency_code) {
$amount = (double) $default_amount;
} else {
$default_amount_model = new InvoicePayment();
$default_amount_model->default_currency_code = $invoice->currency_code;
$default_amount_model->amount = $default_amount;
$default_amount_model->currency_code = $item->currency_code;
$default_amount_model->currency_rate = $_currencies[$item->currency_code];
$default_amount = (double) $default_amount_model->getDivideConvertedAmount();
$convert_amount = new InvoicePayment();
$convert_amount->default_currency_code = $item->currency_code;
$convert_amount->amount = $default_amount;
$convert_amount->currency_code = $invoice->currency_code;
$convert_amount->currency_rate = $_currencies[$invoice->currency_code];
$amount = (double) $convert_amount->getDynamicConvertedAmount();
}
$paid += $amount;
}
}
return $paid;
}
}

View File

@ -0,0 +1,154 @@
<?php
namespace App\Http\Controllers\Modals;
use App\Abstracts\Http\Controller;
use App\Events\Income\PaymentReceived;
use App\Http\Requests\Banking\Transaction as Request;
use App\Models\Banking\Account;
use App\Models\Banking\Transaction;
use App\Models\Income\Invoice;
use App\Models\Setting\Currency;
use App\Utilities\Modules;
use App\Traits\Uploads;
class InvoiceTransactions extends Controller
{
use Uploads;
/**
* Instantiate a new controller instance.
*/
public function __construct()
{
// Add CRUD permission check
$this->middleware('permission:create-incomes-invoices')->only(['create', 'store', 'duplicate', 'import']);
$this->middleware('permission:read-incomes-invoices')->only(['index', 'show', 'edit', 'export']);
$this->middleware('permission:update-incomes-invoices')->only(['update', 'enable', 'disable']);
$this->middleware('permission:delete-incomes-invoices')->only('destroy');
}
/**
* Show the form for creating a new resource.
*
* @param Invoice $invoice
*
* @return Response
*/
public function create(Invoice $invoice)
{
$accounts = Account::enabled()->orderBy('name')->pluck('name', 'id');
$currencies = Currency::enabled()->orderBy('name')->pluck('name', 'code')->toArray();
$currency = Currency::where('code', $invoice->currency_code)->first();
$payment_methods = Modules::getPaymentMethods();
$paid = $this->getPaidAmount($invoice);
// Get Invoice Totals
foreach ($invoice->totals as $invoice_total) {
$invoice->{$invoice_total->code} = $invoice_total->amount;
}
$total = money($invoice->total, $currency->code, true)->format();
//$total = money(0, $currency->code, true)->format();
$invoice->grand_total = money($total, $currency->code)->getAmount();
if (!empty($paid)) {
$invoice->grand_total = round($invoice->total - $paid, $currency->precision) ;
}
$rand = rand();
$html = view('modals.invoices.payment', compact('invoice', 'accounts', 'currencies', 'currency', 'payment_methods', 'rand'))->render();
return response()->json([
'success' => true,
'error' => false,
'message' => 'null',
'html' => $html,
]);
}
/**
* Store a newly created resource in storage.
*
* @param Invoice $invoice
* @param Request $request
*
* @return Response
*/
public function store(Invoice $invoice, Request $request)
{
try {
event(new PaymentReceived($invoice, $request));
$message = trans('messages.success.added', ['type' => trans_choice('general.payments', 1)]);
flash($message)->success();
$response = [
'success' => true,
'error' => false,
'message' => $message,
'redirect' => route('invoices.show', $invoice->id),
];
} catch(\Exception $e) {
$message = $e->getMessage();
//flash($message)->error();
$response = [
'success' => false,
'error' => true,
'message' => $message,
'redirect' => null,
];
}
return response()->json($response);
}
protected function getPaidAmount($invoice)
{
$paid = 0;
// Get Invoice Payments
if (!$invoice->payments->count()) {
return $paid;
}
$_currencies = Currency::enabled()->pluck('rate', 'code')->toArray();
foreach ($invoice->payments as $item) {
$default_amount = $item->amount;
if ($invoice->currency_code == $item->currency_code) {
$amount = (double) $default_amount;
} else {
$default_amount_model = new Transaction();
$default_amount_model->default_currency_code = $invoice->currency_code;
$default_amount_model->amount = $default_amount;
$default_amount_model->currency_code = $item->currency_code;
$default_amount_model->currency_rate = $_currencies[$item->currency_code];
$default_amount = (double) $default_amount_model->getDivideConvertedAmount();
$convert_amount_model = new Transaction();
$convert_amount_model->default_currency_code = $item->currency_code;
$convert_amount_model->amount = $default_amount;
$convert_amount_model->currency_code = $invoice->currency_code;
$convert_amount_model->currency_rate = $_currencies[$invoice->currency_code];
$amount = (double) $convert_amount_model->getAmountConvertedFromCustomDefault();
}
$paid += $amount;
}
return $paid;
}
}

View File

@ -2,7 +2,7 @@
namespace App\Http\Controllers\Modals;
use App\Http\Controllers\Controller;
use App\Abstracts\Http\Controller;
use App\Http\Requests\Setting\Tax as Request;
use App\Models\Setting\Tax;

View File

@ -2,24 +2,13 @@
namespace App\Http\Controllers\Modals;
use App\Http\Controllers\Controller;
use App\Http\Requests\Expense\Vendor as Request;
use App\Models\Expense\Bill;
use App\Models\Expense\Payment;
use App\Models\Expense\Vendor;
use App\Abstracts\Http\Controller;
use App\Http\Requests\Common\Contact as Request;
use App\Models\Common\Contact;
use App\Models\Setting\Currency;
use App\Traits\Uploads;
use App\Utilities\Import;
use App\Utilities\ImportFile;
use Date;
use Illuminate\Pagination\Paginator;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
class Vendors extends Controller
{
use Uploads;
/**
* Instantiate a new controller instance.
*/
@ -39,17 +28,17 @@ class Vendors extends Controller
*/
public function create()
{
$currencies = Currency::enabled()->pluck('name', 'code');
$currencies = Currency::enabled()->orderBy('name')->pluck('name', 'code')->toArray();
$vendor_selector = false;
$contact_selector = false;
if (request()->has('vendor_selector')) {
$vendor_selector = request()->get('vendor_selector');
if (request()->has('contact_selector')) {
$contact_selector = request()->get('contact_selector');
}
$rand = rand();
$html = view('modals.vendors.create', compact('currencies', 'vendor_selector', 'rand'))->render();
$html = view('modals.vendors.create', compact('currencies', 'contact_selector', 'rand'))->render();
return response()->json([
'success' => true,
@ -70,21 +59,14 @@ class Vendors extends Controller
{
$request['enabled'] = 1;
$vendor = Vendor::create($request->all());
// Upload logo
if ($request->file('logo')) {
$media = $this->getMedia($request->file('logo'), 'vendors');
$vendor->attachMedia($media, 'logo');
}
$contact = Contact::create($request->all());
$message = trans('messages.success.added', ['type' => trans_choice('general.vendors', 1)]);
return response()->json([
'success' => true,
'error' => false,
'data' => $vendor,
'data' => $contact,
'message' => $message,
'html' => 'null',
]);