113 lines
No EOL
3.2 KiB
PHP
113 lines
No EOL
3.2 KiB
PHP
<?php
|
|
|
|
namespace App\Repositories;
|
|
|
|
use App\User;
|
|
|
|
|
|
class UserRepository extends BaseRepository {
|
|
|
|
|
|
public function __construct(User $model)
|
|
{
|
|
$this->model = $model;
|
|
}
|
|
|
|
|
|
/**
|
|
* refresh.
|
|
*/
|
|
/*public function update($data)
|
|
{
|
|
|
|
if($data['user_id'] == "new"){
|
|
|
|
$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;
|
|
}
|
|
|
|
$account->company = $data['company'];
|
|
|
|
$account->company_name = $data['company_name'];
|
|
$account->company_street = $data['company_street'];
|
|
$account->company_postal_code = $data['company_postal_code'];
|
|
$account->company_city = $data['company_city'];
|
|
$account->company_country_id = isset($data['company_country_id']) ? $data['company_country_id'] : null;
|
|
|
|
$account->company_pre_phone_id = isset($data['company_pre_phone_id']) ? $data['company_pre_phone_id']: null;
|
|
$account->company_phone = $data['company_phone'];
|
|
$account->company_homepage = $data['company_homepage'];
|
|
|
|
|
|
$account->position_text = $data['position_text'];
|
|
$account->salutation = $data['salutation'];
|
|
$account->title = $data['title'];
|
|
$account->first_name = $data['first_name'];
|
|
$account->last_name = $data['last_name'];
|
|
|
|
$account->street = $data['street'];
|
|
$account->postal_code = $data['postal_code'];
|
|
$account->city = $data['city'];
|
|
$account->country_id = isset($data['country_id']) ? $data['country_id'] : null;
|
|
|
|
$account->pre_phone_id = isset($data['pre_phone_id']) ? $data['pre_phone_id']: null;
|
|
$account->phone = $data['phone'];
|
|
|
|
$account->pre_mobil_id = isset($data['pre_mobil_id']) ? $data['pre_mobil_id']: null;
|
|
$account->mobil = $data['mobil'];
|
|
|
|
$account->contactpartner = $data['contactpartner'];
|
|
|
|
//data_protection
|
|
//active_date
|
|
//active
|
|
$account->save();
|
|
|
|
if(!$this->model->account_id){
|
|
$this->model->account_id = $account->id;
|
|
$this->model->save();
|
|
}
|
|
|
|
$this->updateInterests(isset($data['interests']) ? $data['interests'] : array());
|
|
$this->updateIndustrySector(isset($data['industry_sectors']) ? $data['industry_sectors'] : array());
|
|
|
|
return;
|
|
}
|
|
|
|
*/
|
|
|
|
public function deleteUser(User $user)
|
|
{
|
|
if($user->account){
|
|
$user->account->delete();
|
|
}
|
|
$user->email = "delete".time();
|
|
$user->password = "";
|
|
$user->confirmed = 0;
|
|
$user->confirmation_code = "delete".time();
|
|
$user->confirmation_date = null;
|
|
$user->confirmation_code_to = null;
|
|
$user->confirmation_code_remider = 2;
|
|
$user->agreement = null;
|
|
$user->active = 0;
|
|
$user->token = '';
|
|
$user->active_date = null;
|
|
$user->admin = 0;
|
|
$user->save();
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
} |