Add new version in repository
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
<?php
|
||||
namespace App\Repositories\Auth;
|
||||
|
||||
namespace App\Repositories\Core\Auth;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Laratrust\Traits\LaratrustUserTrait;
|
||||
use Yajra\Datatables\Datatables;
|
||||
use Yajra\DataTables\DataTables;
|
||||
|
||||
use App\Models\Core\Auth\Team;
|
||||
use App\Models\Core\Auth\TeamUser;
|
||||
|
||||
use App\Repositories\Core\User\Users;
|
||||
use App\Repositories\Users;
|
||||
|
||||
class Teams
|
||||
{
|
||||
@@ -38,7 +39,32 @@ class Teams
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return Team::get()->pluck('name', 'id');
|
||||
return Team::orderBy('name', 'asc')->get()->pluck('name', 'id')->toArray();
|
||||
}
|
||||
|
||||
public static function getInfo($id)
|
||||
{
|
||||
return Team::find($id);
|
||||
}
|
||||
|
||||
public static function select_all()
|
||||
{
|
||||
return self::getAll()->toArray();
|
||||
}
|
||||
|
||||
public static function select_by_id($id)
|
||||
{
|
||||
return Team::find($id)->toArray();
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return Team::orderBy('name', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function getByName($name)
|
||||
{
|
||||
return Team::where('name', $name)->first();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
@@ -66,15 +92,31 @@ class Teams
|
||||
}
|
||||
}
|
||||
|
||||
// ajoute une équipe/service/direction
|
||||
public static function store($data)
|
||||
{
|
||||
if (isset($data['id']) && $data['id']) {
|
||||
return self::update($data);
|
||||
}
|
||||
return self::create($data);
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return Team::create($data);
|
||||
}
|
||||
|
||||
// met à jour les informations d'une équipe/service/direction
|
||||
public static function update($data)
|
||||
{
|
||||
return Team::find($data['id'])->update($data);
|
||||
}
|
||||
|
||||
public static function count()
|
||||
{
|
||||
return Team::count();
|
||||
}
|
||||
|
||||
public static function toggle_active($id, $active)
|
||||
{
|
||||
return Team::find($id)->update(['active' => $active]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user