mivita/app/Services/SyS/Customers.php
Kevin Adametz 7a040c3e19 06 2022
2022-06-15 18:08:45 +02:00

63 lines
1.8 KiB
PHP

<?php
namespace App\Services\SyS;
use Auth;
use Request;
use App\User;
use App\Models\ShoppingUser;
use App\Models\PaymentMethod;
use App\Services\CustomerPriority;
use App\Repositories\ContractPDFRepository;
class Customers
{
public static function show()
{
$shopping_users = ShoppingUser::where('member_id', '=', NULL)->where('auth_user_id', '=', NULL)->get();
$data = [
'values' => $shopping_users,
'text' => '',
];
return view('sys.tools.customers', $data);
}
public static function store()
{
$data = Request::all();
$ret = "";
if($data['action'] === 'makePaymentMethodsDefault'){
$users = User::where('payment_methods', '=', NULL)->get();
//$users = User::all();
foreach ($users as $user){
$user->payment_methods = PaymentMethod::getDefaultAsArray();
$user->save();
}
}
if($data['action'] === 'checkForAll'){
$shopping_users = CustomerPriority::checkForAll();
}
if($data['action'] === 'checkContractPDF'){
//create PDF
$user = User::findOrFail(80);
$pdf = new ContractPDFRepository($user);
$pdf->_set('disk', 'user');
$pdf->_set('dir', '/'.$user->id.'/documents/');
$pdf->_set('user_id', $user->id);
$pdf->_set('identifier', 'contract');
$pdf->createContractPDF();
}
if(strpos($data['action'], 'checkOne_') !== false){
$id = (int) str_replace('checkOne_', '', $data['action']);
$shopping_user = ShoppingUser::findOrFail($id);
$ret = CustomerPriority::checkOne($shopping_user);
}
\Session()->flash('alert-success', $ret);
return back();
}
}