working version
This commit is contained in:
parent
5a4d7ce7b4
commit
3ea6ec64d9
@ -3,11 +3,11 @@
|
||||
namespace App\DAL\Studies;
|
||||
|
||||
use App\Models\Study;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Illuminate\Contracts\Database\Eloquent\Builder;
|
||||
|
||||
class AdminStudyLister extends UserStudyListerBase
|
||||
{
|
||||
protected static function defaultQuery(?int $user_id = null): Builder
|
||||
protected function buildQuery(?int $user_id = null): Builder
|
||||
{
|
||||
return self::defaultSortQuery(Study::active());
|
||||
}
|
||||
|
@ -3,11 +3,11 @@
|
||||
namespace App\DAL\Studies;
|
||||
|
||||
use App\Models\Study;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Illuminate\Contracts\Database\Eloquent\Builder;
|
||||
|
||||
class RadiologistStudyLister extends UserStudyListerBase
|
||||
{
|
||||
protected static function defaultQuery(?int $user_id = null): Builder
|
||||
protected function buildQuery(?int $user_id = null): Builder
|
||||
{
|
||||
$user_id = (int) ($user_id ?? auth()->id());
|
||||
|
||||
|
@ -3,11 +3,11 @@
|
||||
namespace App\DAL\Studies;
|
||||
|
||||
use App\Models\Study;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Illuminate\Contracts\Database\Eloquent\Builder;
|
||||
|
||||
class TechnicianStudyLister extends UserStudyListerBase
|
||||
{
|
||||
protected static function defaultQuery(?int $user_id = null): Builder
|
||||
protected function buildQuery(?int $user_id = null): Builder
|
||||
{
|
||||
$query = Study::active();
|
||||
$facility_id = auth()->user()->facility_id;
|
||||
|
@ -3,8 +3,8 @@
|
||||
namespace App\DAL\Studies;
|
||||
|
||||
use App\Models\Enums\ReportStatus;
|
||||
use Illuminate\Contracts\Database\Eloquent\Builder;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
|
||||
abstract class UserStudyListerBase implements IUserStudyLister
|
||||
{
|
||||
@ -25,23 +25,23 @@ protected static function reportPendingQuery(Builder $query): Builder
|
||||
return $query->where('report_status', '<', ReportStatus::Finalized->value);
|
||||
}
|
||||
|
||||
abstract protected static function defaultQuery(?int $user_id = null): Builder;
|
||||
abstract protected function buildQuery(?int $user_id = null): Builder;
|
||||
|
||||
public function all(?int $user_id = null): LengthAwarePaginator
|
||||
{
|
||||
return self::defaultQuery($user_id)
|
||||
return $this->buildQuery($user_id)
|
||||
->paginate(user_per_page($user_id));
|
||||
}
|
||||
|
||||
public function pending(?int $user_id = null): LengthAwarePaginator
|
||||
{
|
||||
return self::reportPendingQuery(self::defaultQuery($user_id))
|
||||
return self::reportPendingQuery(self::buildQuery($user_id))
|
||||
->paginate(user_per_page($user_id));
|
||||
}
|
||||
|
||||
public function completed(?int $user_id = null): LengthAwarePaginator
|
||||
{
|
||||
return self::reportCompleteQuery(self::defaultQuery($user_id))
|
||||
return self::reportCompleteQuery(self::buildQuery($user_id))
|
||||
->paginate(user_per_page($user_id));
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers\Staff;
|
||||
|
||||
use App\DAL\Studies\UserStudyListerFactory;
|
||||
use App\Http\Controllers\HashidControllerBase;
|
||||
use App\Models\Study;
|
||||
use App\Services\AuditTrail\Activity;
|
||||
@ -10,9 +11,7 @@ class StudiesController extends HashidControllerBase
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$studies = Study::active()
|
||||
->orderBy('study_date', 'desc')
|
||||
->paginate(15);
|
||||
$studies = UserStudyListerFactory::getLister()->all();
|
||||
|
||||
return view('staff.studies.index', compact('studies'));
|
||||
}
|
||||
|
208
config/settings.php
Normal file
208
config/settings.php
Normal file
@ -0,0 +1,208 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
return [
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Settings Table
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Database table used to store settings in.
|
||||
|
|
||||
*/
|
||||
'table' => 'settings',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Caching
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| If enabled, all settings are cached after accessing them.
|
||||
|
|
||||
*/
|
||||
'cache' => true,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache Key Prefix
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Specify a prefix to prepend to any setting key being cached.
|
||||
|
|
||||
*/
|
||||
'cache_key_prefix' => 'settings.',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Encryption
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| If enabled, all values are encrypted and decrypted.
|
||||
|
|
||||
*/
|
||||
'encryption' => true,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The driver to use to store and retrieve settings from. You are free
|
||||
| to add more drivers in the `drivers` configuration below.
|
||||
|
|
||||
*/
|
||||
'driver' => env('SETTINGS_DRIVER', 'eloquent'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Drivers
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the driver information for each repository that
|
||||
| is used by your application. A default configuration has been added
|
||||
| for each back-end shipped with this package. You are free to add more.
|
||||
|
|
||||
| Each driver you add must implement the \Rawilk\Settings\Contracts\Driver interface.
|
||||
|
|
||||
*/
|
||||
'drivers' => [
|
||||
'database' => [
|
||||
'driver' => 'database',
|
||||
'connection' => env('DB_CONNECTION', 'mysql'),
|
||||
],
|
||||
'eloquent' => [
|
||||
'driver' => 'eloquent',
|
||||
|
||||
/*
|
||||
* You can use any model you like for the setting, but it needs to implement
|
||||
* the \Rawilk\Settings\Contracts\Setting interface.
|
||||
*/
|
||||
'model' => \Rawilk\Settings\Models\Setting::class,
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Teams
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When set to true the package implements teams using the `team_foreign_key`.
|
||||
|
|
||||
| If you want the migrations to register the `team_foreign_key`, you must
|
||||
| set this to true before running the migration.
|
||||
|
|
||||
| If you already ran the migrations, then you must make a new migration to
|
||||
| add the `team_foreign_key` column to the settings table, and update the
|
||||
| unique constraint on the table. See the `add_settings_team_field` migration
|
||||
| for how to do this.
|
||||
|
|
||||
*/
|
||||
'teams' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Team Foreign Key
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When teams is set to true, our database/eloquent drivers will use this
|
||||
| column as a team foreign key to scope queries to.
|
||||
|
|
||||
| The team id will also be included in a cache key when caching is enabled.
|
||||
|
|
||||
*/
|
||||
'team_foreign_key' => 'team_id',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Context Serializer
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The context serializer is responsible for converting a Context object
|
||||
| into a string, which gets appended to a setting key in the database.
|
||||
|
|
||||
| Any custom serializer you use must implement the
|
||||
| \Rawilk\Settings\Contracts\ContextSerializer interface.
|
||||
|
|
||||
| Supported:
|
||||
| - \Rawilk\Settings\Support\ContextSerializers\ContextSerializer (default)
|
||||
| - \Rawilk\Settings\Support\ContextSerializers\DotNotationContextSerializer
|
||||
|
|
||||
*/
|
||||
'context_serializer' => \Rawilk\Settings\Support\ContextSerializers\ContextSerializer::class,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Key Generator
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The key generator is responsible for generating a suitable key for a
|
||||
| setting.
|
||||
|
|
||||
| Any custom key generator you use must implement the
|
||||
| \Rawilk\Settings\Contracts\KeyGenerator interface.
|
||||
|
|
||||
| Supported:
|
||||
| - \Rawilk\Settings\Support\KeyGenerators\ReadableKeyGenerator
|
||||
| - \Rawilk\Settings\Support\KeyGenerators\Md5KeyGenerator (default)
|
||||
| - \Rawilk\Settings\Support\KeyGenerators\HashKeyGenerator
|
||||
|
|
||||
*/
|
||||
'key_generator' => \Rawilk\Settings\Support\KeyGenerators\Md5KeyGenerator::class,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Value Serializer
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| By default, we use php's serialize() and unserialize() functions to
|
||||
| prepare the setting values for storage. You may use the `JsonValueSerializer`
|
||||
| instead if you want to store the values as json instead.
|
||||
|
|
||||
| Any custom value serializer you use must implement the
|
||||
| \Rawilk\Settings\Contracts\ValueSerializer interface.
|
||||
|
|
||||
*/
|
||||
'value_serializer' => \Rawilk\Settings\Support\ValueSerializers\ValueSerializer::class,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache Default Value
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When a setting is not persisted, we will cache the passed in default value
|
||||
| if this is set to true. This may not always be desirable, so you can
|
||||
| disable it here if needed.
|
||||
|
|
||||
*/
|
||||
'cache_default_value' => true,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Unserialize Safelist
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using the default value serializer class from this package, we
|
||||
| will only unserialize objects that have their classes safelisted here.
|
||||
| Any other objects will be unserialized to something like:
|
||||
| __PHP_Incomplete_Class(App\Models\User) {...}
|
||||
|
|
||||
| To prevent any objects from being unserialized, simply set this to
|
||||
| an empty array.
|
||||
*/
|
||||
'unserialize_safelist' => [
|
||||
\Carbon\Carbon::class,
|
||||
\Carbon\CarbonImmutable::class,
|
||||
\Illuminate\Support\Carbon::class,
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Hash Algorithm
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The hashing algorithm to use for the HashKeyGenerator.
|
||||
|
|
||||
*/
|
||||
'hash_algorithm' => 'xxh128',
|
||||
];
|
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create(config('settings.table'), function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('key')->unique()->index();
|
||||
$table->longText('value')->nullable();
|
||||
});
|
||||
}
|
||||
};
|
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if (! config('settings.teams')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::table(config('settings.table'), function (Blueprint $table) {
|
||||
$table->unsignedBigInteger(config('settings.team_foreign_key'))->nullable()->after('id');
|
||||
$table->index(config('settings.team_foreign_key'), 'settings_team_id_index');
|
||||
|
||||
$table->dropUnique('settings_key_unique');
|
||||
|
||||
$table->unique([
|
||||
'key',
|
||||
config('settings.team_foreign_key'),
|
||||
], 'settings_key_team_id_unique');
|
||||
});
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue
Block a user