Настройки приложения правятся из панели поверх .env
Реестр настроек живёт в коде (config/settings.php для своих), в базе только значения. Сброс убирает значение из базы — и снова работает .env.
This commit is contained in:
1 parent
974a3409d5
commit
387f79851b
13 files changed
+858
-2
No files matched your search
@@ -13,6 +13,7 @@ use Rsgrinko\Proton\Http\Controller;
|
||||
use Rsgrinko\Proton\Http\Request;
|
||||
use Rsgrinko\Proton\Http\Response;
|
||||
use Rsgrinko\Proton\Support\Audit;
|
||||
use Rsgrinko\Proton\Support\Config;
|
||||
use Rsgrinko\Proton\Support\ProtonException;
|
||||
|
||||
/**
|
||||
@@ -62,6 +63,15 @@ final class NotesController extends Controller
|
||||
'pinned' => 'nullable|boolean',
|
||||
], ['title' => 'Название', 'body' => 'Текст']);
|
||||
|
||||
$limit = (int) Config::get('notes.per_user', 0);
|
||||
|
||||
// Ограничение правится из панели; 0 — без ограничения
|
||||
if ($limit > 0 && Note::query()->where('user_id', $viewer->id())->count() >= $limit) {
|
||||
$this->flash('Заметок уже ' . $limit . ', больше настройка не разрешает', 'error');
|
||||
|
||||
return $this->redirect('notes.index');
|
||||
}
|
||||
|
||||
$note = new Note($data);
|
||||
|
||||
$note->setAttribute('user_id', $viewer->id());
|
||||
|
||||
Reference in new issue
Block a user