First Commit
This commit is contained in:
commit
610aa1e202
4204 changed files with 636764 additions and 0 deletions
68
app/Repositories/BaseRepository.php
Normal file
68
app/Repositories/BaseRepository.php
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
namespace App\Repositories;
|
||||
|
||||
abstract class BaseRepository {
|
||||
|
||||
/**
|
||||
* The Model instance.
|
||||
*
|
||||
* @var Illuminate\Database\Eloquent\Model
|
||||
*/
|
||||
protected $model;
|
||||
|
||||
/**
|
||||
* Get number of records.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getNumber()
|
||||
{
|
||||
$total = $this->model->count();
|
||||
|
||||
$new = $this->model->whereSeen(0)->count();
|
||||
|
||||
return compact('total', 'new');
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy a model.
|
||||
*
|
||||
* @param int $id
|
||||
* @return void
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$this->getById($id)->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Model by id.
|
||||
*
|
||||
* @param int $id
|
||||
* @return App\Models\Model
|
||||
*/
|
||||
public function getById($id)
|
||||
{
|
||||
return $this->model->findOrFail($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Model by id.
|
||||
*
|
||||
* @param int $id
|
||||
* @return App\Models\Model
|
||||
*/
|
||||
public function getAll()
|
||||
{
|
||||
return $this->model->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Illuminate\Database\Eloquent\Model
|
||||
*/
|
||||
public function getModel()
|
||||
{
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
}
|
||||
113
app/Repositories/UserRepository.php
Normal file
113
app/Repositories/UserRepository.php
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
<?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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue