2016-07-14 22:37:04 +02:00
|
|
|
<?php
|
2015-11-05 23:37:04 +01:00
|
|
|
|
2016-07-14 22:37:04 +02:00
|
|
|
namespace App\Ninja\Repositories;
|
|
|
|
|
|
|
|
use App\Models\User;
|
2015-11-05 23:37:04 +01:00
|
|
|
use DB;
|
|
|
|
use Session;
|
|
|
|
|
2016-07-14 22:37:04 +02:00
|
|
|
/**
|
|
|
|
* Class UserRepository
|
|
|
|
*/
|
2015-11-05 23:37:04 +01:00
|
|
|
class UserRepository extends BaseRepository
|
|
|
|
{
|
2016-07-14 22:37:04 +02:00
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
2015-11-05 23:37:04 +01:00
|
|
|
public function getClassName()
|
|
|
|
{
|
|
|
|
return 'App\Models\User';
|
|
|
|
}
|
|
|
|
|
2016-07-14 22:37:04 +02:00
|
|
|
/**
|
|
|
|
* @param $accountId
|
|
|
|
*
|
|
|
|
* @return $this
|
|
|
|
*/
|
2015-11-05 23:37:04 +01:00
|
|
|
public function find($accountId)
|
|
|
|
{
|
|
|
|
$query = DB::table('users')
|
|
|
|
->where('users.account_id', '=', $accountId);
|
|
|
|
|
|
|
|
if (!Session::get('show_trash:user')) {
|
|
|
|
$query->where('users.deleted_at', '=', null);
|
|
|
|
}
|
|
|
|
|
2016-03-16 00:08:00 +01:00
|
|
|
$query->select('users.public_id', 'users.first_name', 'users.last_name', 'users.email', 'users.confirmed', 'users.public_id', 'users.deleted_at', 'users.is_admin', 'users.permissions');
|
2015-11-05 23:37:04 +01:00
|
|
|
|
|
|
|
return $query;
|
|
|
|
}
|
2016-02-04 21:35:28 +01:00
|
|
|
|
2016-07-14 22:37:04 +02:00
|
|
|
/**
|
|
|
|
* @param array $data
|
|
|
|
* @param User $user
|
|
|
|
*
|
|
|
|
* @return User
|
|
|
|
*/
|
|
|
|
public function save(array $data, User $user)
|
2016-02-04 21:35:28 +01:00
|
|
|
{
|
|
|
|
$user->fill($data);
|
|
|
|
$user->save();
|
|
|
|
|
|
|
|
return $user;
|
|
|
|
}
|
2015-11-05 23:37:04 +01:00
|
|
|
}
|