I'm creating a web app where I need to get the id's of the accounts that will act as benchmark accounts, at the moment what I thought is to have a separate file called bench-accounts where I'll be able to get the id and the color of each account. Then I use config('bench-accounts') to be able to get the accounts and filter them as I want. I did it this way because whoever manages this will be able to get the id of the account from the database then add it here and have it act as a benchmark account (since I think it will be the best way for people that doesn't have a lot of knowledge with programming)
The file would follow the next structure:
<?php
return [
1 => [
'id' => 1,
'color' => '#00cfff',
],
2 => [
'id' => 2,
'color' => '#ff0000',
],
130 => [
'id' => 130,
'color' => '#fff200',
],
149 => [
'id' => 149,
'color' => '#3F220F',
],
168 => [
'id' => 168,
'color' => '#00ff0f',
],
169 => [
'id' => 169,
'color' => '#5438DC',
],
170 => [
'id' => 170,
'color' => '#3E517A',
]
];
Is it correct? I'm planning on adding an active parameter so that in the future you'll be able to activate or disable it on which accounts you want to benchmark and which not.
Tried it adding the account to a config file where it will have different parameters and the ids of the accounts.
Related
I'm using Stripe PHP SDK to create a subscription plan dynamically.
use \Stripe\Plan;
Plan::create(array(
"amount" => 2000,
"interval" => "month",
"name" => "Amazing Gold Plan",
"currency" => "usd",
"id" => "gold")
);
I wanted to ask is there a way to mention/handle the duration of a plan. Like I wanted to make a subscription by the plan for a limited time suppose 3 months and after 3 months I wanted the plan to automatically get removed from the subscription. I don't want to cancel the whole subscription as in my case there could be multiple plans associated with a subscription. SO I simply want to remove/detach the plan from the subscription.
I had gone through the Stripe SDK docs to find this but to no avail.
A Subscription Schedule [1] will be what you require here to automate changes to the underlying Subscription using phases [2].
The use of a schedule will allow you to specify, for example, a monthly Price that will iterate for 3 months in the first phase. Then you can define in the next phase what will happen, for example change the Prices in some way, like adding or removing Prices. An example may look like this:
\Stripe\SubscriptionSchedule::create([
'customer' => 'cus_xxx',
'start_date' => 'now',
'end_behavior' => 'release',
'phases' => [
[
'items' => [
[
'price' => 'price_print', # Monthly Price
'quantity' => 1,
],
],
'iterations' => 3, # Iterates for 3 months
],
[
'items' => [
[
'price' => 'price_print',
'quantity' => 1,
],
[
'price' => 'price_digital', # An extra price
'quantity' => 1,
],
],
'iterations' => 1, # Iterate for 1 month
],
],
]);
[1] https://stripe.com/docs/billing/subscriptions/subscription-schedules#managing
[2] https://stripe.com/docs/api/subscription_schedules/object#subscription_schedule_object-phases
I believe you need to create price instead of plan and the code would be like this (Not sure I use different platform but you can try)
use \Stripe\Plan;
$price = \Stripe\Price::create([
'product' => '{{PRODUCT_ID}}',
'unit_amount' => 1000,
'currency' => 'usd',
'recurring' => [
'interval' => 'month',
'interval_count' => 2 //Try tweaking this value for change
],
]);
I'm trying to change a ranges colour via the Google Sheets API in PHP.
I have done around an hour of researchig. The code below is as far as I've got.
$requests = [
// Change the spreadsheet's title.
new Google_Service_Sheets_Request([
'updateSpreadsheetProperties' => [
'properties' => [
'title' => "The Title"
],
'fields' => 'title'
],
'UpdateCellsRequest' => [
'properties' => [
'range' => "Sheet1!A1",
'backgroundColor' => "#000"
],
'fields' => ''
]
])
];
// Add additional requests (operations) ...
$batchUpdateRequest = new Google_Service_Sheets_BatchUpdateSpreadsheetRequest([
'requests' => $requests
]);
$response = $GoogleSheetsAPIHandler->sheets->spreadsheets->batchUpdate("SHEETID", $batchUpdateRequest);
print_r($response);
If I take out this:
'UpdateCellsRequest' => [
'properties' => [
'range' => "Sheet1!A1",
'backgroundColor' => "#000"
],
'fields' => ''
]
Then the code works to update the sheets title. However, I can't seem to update a ranges colour.
Any advice would be greatly appreciated!
I believe your goal and situation as follows.
You want to change the background color of cells using googleapis for php.
You have already been able to get and put values for Google Spreadsheet using Sheets API.
Modification points:
When you want to use the batchUpdate method of Sheets API, please put each request to each element of the array of requests.
I think that the request body of UpdateCellsRequest in your script is not correct.
From your question of I'm trying to change a ranges colour via the Google Sheets API in PHP., when you want to change the background color of several cells with one color, I think that RepeatCellRequest might be suitable.
In this answer, I would like to propose a modified script for changing the several cells using one color. When your script is modified, it becomes as follows.
Modified script:
Before you use this, please set the sheet ID.
$requests = [
new Google_Service_Sheets_Request([
'updateSpreadsheetProperties' => [
'properties' => [
'title' => "The Title"
],
'fields' => 'title'
]
]),
new Google_Service_Sheets_Request([
'repeatCell' => [
'cell' => [
'userEnteredFormat' => [
'backgroundColor' => [
'red' => 1,
'green' => 0,
'blue' => 0
]
]
],
'range' => [
'sheetId' => $sheetId, // <--- Please set the sheet ID.
'startRowIndex' => 0,
'endRowIndex' => 3,
'startColumnIndex' => 0,
'endColumnIndex' => 2
],
'fields' => 'userEnteredFormat'
]
])
];
When above request body is used for the batchUpdate method of Sheets API, the title of Spreadsheet is changed and the background color of the cells "A1:B3" changed to the red color.
Wne you want to use UpdateCellsRequest, you can use the following request body. At the following request body, the background colors of cells "A1:B1" are changed to red and green colors, respectively. When UpdateCellsRequest is used, each cell can be updated. About the detail information of UpdateCellsRequest, please check the official document. Ref
$requests = [
new Google_Service_Sheets_Request([
'updateCells' => [
'rows' => array([
'values' => array(
['userEnteredFormat' => [
'backgroundColor' => [
'red' => 1,
'green' => 0,
'blue' => 0
]
]],
['userEnteredFormat' => [
'backgroundColor' => [
'red' => 0,
'green' => 1,
'blue' => 0
]
]]
)
]),
'range' => [
'sheetId' => $sheetId, // <--- Please set the sheet ID.
'startRowIndex' => 0,
'startColumnIndex' => 0,
],
'fields' => 'userEnteredFormat'
]
])
];
References:
UpdateCellsRequest
RepeatCellRequest
I'm trying to create an e-commerce application from scratch with Vanilo. I've meticulously followed the steps described here several times. However, when it comes to accessing the route in the example http://127.0.0.1:8000/admin/customer, I get a 403 Forbidden error. I've tried many things but this is what I have right now in my concord.php file.
return [
'modules' => [
Konekt\AppShell\Providers\ModuleServiceProvider::class => [
'ui' => [
'name' => 'Vanilo',
'url' => '/admin/product'
]
],
Vanilo\Framework\Providers\ModuleServiceProvider::class => [
'image' => [
'variants' => [
'thumbnail' => [
'width' => 250,
'height' => 188,
'fit' => 'fill'
],
'medium' => [
'width' => 540,
'height' => 406,
'fit' => 'fill'
]
]
],
]
]
];
My user has the role of admin in the database.
How can I access this route?
While creating initial user using php artisan appshell:super keep the role default admin
After creating the user check the role_permissions table. the role must have all the permissions.
I am facing an issue while applying queries on firebase data in PHP.
I want to get online users list from the above offline and online data
that is stored in firebase
actually under user_list I have added user's ids that is dynamic/variables so I can't apply rule on the behalf of this.
[
user_list=>[1 => ['id' => 1, 'name' => 'abbas', 'status' => 'online'], 2 => ['id' => 2, 'naumani' => '1.0,2.0', 'status' => 'online'], 3 => ['id' => 3, 'dev' => '1.0,2.0', 'status' => 'offline'], 4 => ['id' => 4, 'dev' => '1.0,2.0', 'status' => 'offline']]
]
I found the solutions from the documentations:
https://firebase.google.com/docs/database/security/indexing-data#section-indexing-order-by-value
The example of dinosaurs was very helpful for me.
Steps:
set the rule first:
Then in Admin SDK use orderByChild (Mine is PHP)
I am building an E-commerce project with demo database of products, brands and vendors.I have implemented auto suggest in search bar,it works.
what I am unable to do is fix for spelling errors. For eg-if a user search for Motorola as motoroal no results is given.
Can anybody point me to right direction?
That's not a easy task.
I use the following setup:
'analysis' => [
'filter' => [
'nGram_filter' => [
'type' => 'edgeNGram',
'min_gram' => '1',
'max_gram' => '20',
'token_chars' => [
'letter',
'digit',
'punctuation',
'symbol',
],
],
],
'analyzer' => [
'nGram_analyzer' => [
'type' => 'custom',
'tokenizer' => 'whitespace',
'filter' => [
'lowercase',
'asciifolding',
'nGram_filter',
],
],
]
]
Then I set my fields map to use the nGram_analyzer as analyzer.
The edgeNGram tokenizer will break your words in this way:
motorola will be break into: m mo mot moto motor motoro motorol motorola
This setup will act like an auto complete, predicting what your user is trying to search.
To help with spelling errors, you will need to apply some similar analyzer to the search_analyzer on your field mapping.