PluginProbe
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments / 1.0.5
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments v1.0.5
4.7.2 4.7.1 4.7.0 4.6.6 4.6.5 4.6.4 4.6.3 4.6.2 4.6.1 4.6.0 4.5.1 4.5.0 4.4.2 4.4.1 4.4.0 4.3.3 4.3.2 4.3.1 4.3.0 4.2.3 4.2.2 4.2.1 1.0.3 1.0.4 1.0.5 All 281 releases
surecart / app / src / Settings / Setting / AccountSetting.php
AccountSetting.php
57 lines 1021 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace SureCart\Settings\Setting;
3
4 use SureCart\Models\Account;
5 use SureCart\Settings\RegisterSetting;
6 use SureCart\Settings\RegisterSettingInterface;
7
8 /**
9 * Provides an account setting to register.
10 */
11 class AccountSetting extends RegisterSetting implements RegisterSettingInterface {
12 /**
13 * Slug for the setting
14 *
15 * @since 1.0
16 * @var string $slug
17 */
18 protected $name = 'account';
19
20 /**
21 * Setting REST API Schema
22 *
23 * @var array
24 */
25 protected $schema = [
26 'name' => [
27 'type' => 'string',
28 ],
29 'currency' => [
30 'type' => 'string',
31 ],
32 ];
33
34 /**
35 * What to return when settings are indexed.
36 */
37 public function index( $settings, $params ) {
38 $account = Account::find();
39 return [
40 'name' => $account->name,
41 'currency' => $account->currency,
42 ];
43 }
44
45 /**
46 * What to return when settings are updated.
47 */
48 public function update( $values = [] ) {
49 return Account::update(
50 [
51 'name' => $values['name'],
52 'currency' => $values['currency'],
53 ]
54 );
55 }
56 }
57