-
Notifications
You must be signed in to change notification settings - Fork 473
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
32 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,9 +18,24 @@ | |
* +----------------------------------------------------------------------+ | ||
*/ | ||
|
||
return [ | ||
namespace SlimKit\PlusCheckIn\Seeds; | ||
|
||
'open' => false, | ||
'attach_balance' => 1, | ||
use Illuminate\Database\Seeder; | ||
use function Zhiyi\Plus\setting; | ||
|
||
]; | ||
class SettingsTableSeeder extends Seeder | ||
{ | ||
/** | ||
* Run the package seeder. | ||
* | ||
* @return void | ||
* @author Seven Du <[email protected]> | ||
*/ | ||
public function run() | ||
{ | ||
setting('checkin')->set([ | ||
'switch' => true, | ||
'attach-balance' => 1, | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,29 +21,11 @@ | |
namespace SlimKit\PlusCheckIn\API\Middleware; | ||
|
||
use Closure; | ||
use function Zhiyi\Plus\setting; | ||
use Illuminate\Auth\Access\AuthorizationException; | ||
use Illuminate\Contracts\Config\Repository as ConfigRepository; | ||
|
||
class CheckInSwitch | ||
{ | ||
/** | ||
* ThinkSNS+ config repository. | ||
* | ||
* @var \Illuminate\Contracts\Config\Repository | ||
*/ | ||
protected $config; | ||
|
||
/** | ||
* Create the middleware. | ||
* | ||
* @param \Illuminate\Contracts\Config\Repository $config | ||
* @author Seven Du <[email protected]> | ||
*/ | ||
public function __construct(ConfigRepository $config) | ||
{ | ||
$this->config = $config; | ||
} | ||
|
||
/** | ||
* The middleware handle. | ||
* | ||
|
@@ -54,7 +36,7 @@ public function __construct(ConfigRepository $config) | |
*/ | ||
public function handle($request, Closure $next) | ||
{ | ||
if (! $this->config->get('checkin.open')) { | ||
if (! setting('checkin', 'switch', false)) { | ||
throw new AuthorizationException( | ||
trans('plus-checkin::messages.checkin-closed') | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ | |
|
||
namespace SlimKit\PlusCheckIn\Admin\Controllers; | ||
|
||
use Zhiyi\Plus\Support\Configuration; | ||
use function Zhiyi\Plus\setting; | ||
use SlimKit\PlusCheckIn\Admin\Requests\StoreConfig as StoreConfigRequest; | ||
|
||
class HomeController | ||
|
@@ -34,27 +34,23 @@ class HomeController | |
public function index() | ||
{ | ||
return view('plus-checkin::admin', [ | ||
'switch' => config('checkin.open'), | ||
'balance' => config('checkin.attach_balance'), | ||
'switch' => setting('checkin', 'switch'), | ||
'balance' => setting('checkin', 'attach-balance'), | ||
]); | ||
} | ||
|
||
/** | ||
* Store checkin config. | ||
* | ||
* @param \SlimKit\PlusCheckIn\Admin\Requests\StoreConfig $request | ||
* @param \Zhiyi\Plus\Support\Configuration $config | ||
* @return mixed | ||
* @author Seven Du <[email protected]> | ||
*/ | ||
public function store(StoreConfigRequest $request, Configuration $config) | ||
public function store(StoreConfigRequest $request) | ||
{ | ||
$switch = (bool) $request->input('switch'); | ||
$balance = (int) $request->input('balance'); | ||
|
||
$config->set([ | ||
'checkin.open' => $switch, | ||
'checkin.attach_balance' => $balance, | ||
setting('checkin')->set([ | ||
'switch' => (bool) $request->input('switch'), | ||
'attach-balance' => (int) $request->input('balance'), | ||
]); | ||
|
||
return redirect()->back()->with('message', trans('plus-checkin::messages.success')); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters