mivita/app/Repositories/CustomerRepository.php
2026-01-23 17:35:23 +01:00

108 lines
3.1 KiB
PHP

<?php
namespace App\Repositories;
use App\Models\ShoppingUser;
class CustomerRepository extends BaseRepository
{
public function __construct()
{
//$this->model = $model;
}
public function deleteCustomer(ShoppingUser $shopping_user)
{
if ($shopping_user->shopping_orders->count() > 0) {
return false;
}
$shopping_user->auth_user_id = null;
$shopping_user->member_id = null;
$shopping_user->billing_salutation = null;
$shopping_user->billing_company = null;
$shopping_user->billing_firstname = 'Deleted';
$shopping_user->billing_lastname = 'User';
$shopping_user->billing_address = 'Deleted';
$shopping_user->billing_address_2 = null;
$shopping_user->billing_zipcode = '00000';
$shopping_user->billing_city = 'Deleted';
$shopping_user->billing_phone = null;
$shopping_user->billing_email = 'deleted_' . $shopping_user->id . '@deleted.com';
$shopping_user->shipping_salutation = null;
$shopping_user->shipping_company = null;
$shopping_user->shipping_firstname = 'Deleted';
$shopping_user->shipping_lastname = 'User';
$shopping_user->shipping_address = 'Deleted';
$shopping_user->shipping_address_2 = null;
$shopping_user->shipping_zipcode = '00000';
$shopping_user->shipping_city = 'Deleted';
$shopping_user->shipping_phone = null;
$shopping_user->shipping_email = 'deleted_' . $shopping_user->id . '@deleted.com';
$shopping_user->remarks = null;
$shopping_user->notice = null;
$shopping_user->faker_mail = true;
$shopping_user->save();
return true;
}
public function update($data)
{
/*if($data['user_id'] === "new" || $data['user_id'] == 0){
$this->model = User::create([
'email' => $data['email'],
'password' => env('APP_KEY'),
]);
}
else{
$this->model = $this->getById($data['user_id']);
}
if(!$this->model->account_id){
$account = new UserAccount();
}else{
$account = $this->model->account;
}
$data['same_as_billing'] = !isset($data['same_as_billing']) ? 0 : 1;
$account->fill($data)->save();
if(!$this->model->account_id){
$this->model->account_id = $account->id;
$this->model->save();
}*/
return true;
}
public function create($data)
{
/* $this->model = User::create([
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);
$account = UserAccount::create([
'm_salutation' => $data['salutation'],
'm_first_name' => $data['first_name'],
'm_last_name' => $data['last_name'],
'salutation' => $data['salutation'],
'first_name' => $data['first_name'],
'last_name' => $data['last_name'],
]);
$this->model->account_id = $account->id;
$this->model->save();
return $this->model;*/
}
}