[link] [comments]
08 March, 2024
Laravel Request Forwarder
Programing Coderfunda March 08, 2024 No comments
07 March, 2024
How to Create a New Table from JSONB_ARRAY_ELEMENTS and JSONB_OBJECT_KEYS in Postgresql?
Programing Coderfunda March 07, 2024 No comments
It seems like there should be an easy way to create a new table from the keys and values.
Here is the request:
WITH sport_markets_api AS (
SELECT ((CONTENT::jsonb ->> 'data')::jsonb ->> 'sportMarkets')::jsonb AS details
FROM http_post(
'
https://api.thegraph.com/subgraphs/name/',
/> '{"query": "{sportMarkets(first:2,skip:0,orderBy:timestamp,orderDirection:desc){id,timestamp,address,gameId,maturityDate,tags,isOpen,isResolved,isCanceled,finalResult,homeTeam,awayTeam }}"}'::text,
'application/json'))
I tried:
SELECT
jsonb_array_elements(details) ->> jsonb_object_keys(jsonb_array_elements(details))
FROM sport_markets_api
and was expecting a table with columns based on the keys.
Is there a way to set Horizon's timeout on a job class ?
Programing Coderfunda March 07, 2024 No comments
The way it used to work was the job was sent on a regular redis queue, and timeout would be set on the symfony process, effectively making the job run for the time it needed.
Now we want to send the job on a Horizon queue. The timeout is still set on the process, but Horizon's config has its own timeout value in the config. The problem is that the length of the recording will vary from case to case, with an average being 60 minutes, but we do have cases doing for multiple hours.
I could set it up to a very (very) long timeout, but I find it counterintuitive. Isn't there a way that I could specify the value for timeout on a job ? Otherwise, is setting a humongously long timeout the only logical way to do this ? submitted by /u/CouldHaveBeenAPun
[link] [comments]
Group the ones that are the same and right next to each other in sql
Programing Coderfunda March 07, 2024 No comments
websit_id
updated_at
display_id
1222
03-06 06:00
apple
1222
03-06 08:00
apple
1222
03-06 10:00
carrot
1222
03-06 12:00
apple
1222
03-06 14:00
fig
1234
03-06 06:00
apple
1234
03-06 08:00
peach
I wanted to label the rows so that it groups the same display ID that are right next to each other but would not group them if there's something else in btw.
The desired outcome should be the following:
websit_id
updated_at
display_id
group_label
1222
03-06 06:00
apple
1
1222
03-06 08:00
apple
1
1222
03-06 10:00
carrot
2
1222
03-06 12:00
apple
3
1222
03-06 14:00
fig
4
1234
03-06 06:00
apple
1
1234
03-06 08:00
peach
2
I am using snowflake for this.
Async Initializers Swift MVVM not working
Programing Coderfunda March 07, 2024 No comments
import Foundation
import FirebaseFirestore
class ChatViewModel: ObservableObject {
@Published var chat: ChatModel
@Published var opposingUser: User
init(oppUser: User) {
self.opposingUser = oppUser
Task {
if let fetchedChat = try? await fetchChat(oppUser: oppUser) {
self.chat = fetchedChat
}
}
}
init(chat: ChatModel) {
self.chat = chat
Task {
if let fetchedUser = try? await getOpposingUser(chat: chat) {
self.opposingUser = fetchedUser
}
}
}
@MainActor
func fetchChat(oppUser: User) async throws -> ChatModel? {
do {
let documents = try await Firestore.firestore()
.collection("conversations")
.whereField("users", arrayContains: UserService.shared.currentUser?.id ?? "error")
.whereField("users", arrayContains: oppUser.id)
.getDocuments()
for document in documents.documents {
guard let chatData = try? document.data(as: ChatModel.self) else {
print("[DEBUG fetchChat(oppUser: User)]: Error while converting Firebase Document to ChatModel ")
return nil
}
return chatData
}
} catch {
print("[DEBUG fetchChat(oppUser: User)]: \(error)")
throw error // Re-throw the error so it can be handled by the caller if needed
}
return nil
}
@MainActor
func getOpposingUser(chat: ChatModel) async throws -> User? {
do {
let opposingUid: String
if chat.users[0] == UserService.shared.currentUser?.id {
opposingUid = chat.users[1]
} else {
opposingUid = chat.users[0]
}
let document = try await Firestore
.firestore()
.collection("users")
.document(opposingUid)
.getDocument()
guard let opposingUserDoc = try? document.data(as: User.self) else {
// Handle the case where conversion to User fails
print("[DEBUG (getOpposingUser(chat: chatModel)]: Error while converting Firebase-Document to User ")
return nil
}
return opposingUserDoc
} catch {
print("[DEBUG (getOpposingUser(chat: chatModel)]: \(error) ")
throw error
}
return nil
}
}
I tried to "pre initilize" the variables with something like self.chat = ChatModel() but due to the nature of my Cahtmodel I can't init it without properties.
Herd for Windows
Programing Coderfunda March 07, 2024 No comments
https://preview.redd.it/4t22y3gulvmc1.png?width=627&format=png&auto=webp&s=806bbe46479290857bc29f17e853d68667e03639
https://herd.laravel.com/ submitted by /u/VaguelyOnline
[link] [comments]
06 March, 2024
How to type two variables that are correlated in TypeScript?
Programing Coderfunda March 06, 2024 No comments
If I define it in this way, it works
function process1() {
const yAxisType = 'primary';
const otherYAxisType = 'secondary';
return {
[yAxisType]: foo,
[otherYAxisType]: bar
}
}
function process2() {
const yAxisType = 'secondary';
const otherYAxisType = 'primary';
return {
[yAxisType]: foo,
[otherYAxisType]: bar
}
}
I want to merge these two functions. But I kept getting TS errors. How can I resolve it? Thanks!
function process(yAxisType: 'primary' | 'secondary') {
const otherYAxisType = yAxisType === 'primary' ? 'secondary' : 'primary';
return {
[yAxisType]: foo,
[otherYAxisType]: bar
}
}
Type '{ [x: string]: { fields: never[]; } | { type: "quantitative"; }; scale: { type: "quantitative"; }; }' is not assignable to type 'ComboChartAxisEncoding'.
Type '{ [x: string]: { fields: never[]; } | { type: "quantitative"; }; scale: { type: "quantitative"; }; }' is not assignable to type 'ComboChartSingleAxisEncoding'.
Type '{ [x: string]: { fields: never[]; } | { type: "quantitative"; }; scale: { type: "quantitative"; }; }' is missing the following properties from type '{ primary: ComboChartSingleAxisSectionEncoding; secondary: ComboChartSingleAxisSectionEncoding; scale: QuantitativeScale; }': primary, secondaryts(2322)
index.ts(85, 3): The expected type comes from property 'y' which is declared here on type 'ComboChartEncodingMap'
See Minimal repro on TS playground 👈
export type ComboChartAxisEncoding = ComboChartSingleAxisEncoding | ComboChartDualAxisEncoding;
export type ComboChartSingleAxisEncoding = {
primary: ComboChartSingleAxisSectionEncoding;
secondary: ComboChartSingleAxisSectionEncoding;
scale: 'quantitative';
};
export type ComboChartSingleAxisSectionEncoding = {
fields: number[];
};
export type ComboChartDualAxisEncoding = {
primary: ComboChartDualAxisSectionEncoding;
secondary: ComboChartDualAxisSectionEncoding;
};
export type ComboChartDualAxisSectionEncoding = {
fields: number[];
scale: 'quantitative';
};
function process1(): ComboChartAxisEncoding {
const yAxisType: 'primary' | 'secondary' = 'primary';
const otherYAxisType: 'primary' | 'secondary' = 'secondary';
return { // this works
[yAxisType]: { fields: [] },
[otherYAxisType]: { fields: [] },
scale: 'quantitative',
};
}
function process2(yAxisType: T): ComboChartAxisEncoding {
const otherYAxisType = (yAxisType === 'primary' ? 'secondary' : 'secondary') as (T extends 'primary' ? 'secondary' : 'primary');
// this doesn't work. Note that in my case this function wraps lots of test cases and each of them has this structure.
// So, if I don't have to change the structure of the JS objects, and just need to change the types, it would be better.
return {
[yAxisType]: { fields: [] },
[otherYAxisType]: { fields: [] },
scale: 'quantitative',
};
}
Receiving Incoming SMS post Android 8
Programing Coderfunda March 06, 2024 No comments
* Background Service Limitations
* Broadcast Limitations
TL;DR: Starting Android 8 the OS will stop your Services and Broadcast Receivers except in some situations mentioned in above documents.
What is then a proper way to detect incoming sms? We can use WorkManager to manually query the SMS to check for new entries every 15 minutes. But what would be a way to get it instantly?
Also the official docs list the SMS_RECEIVE intent in the list of broadcasts that are exceptions to the above rules, but many have found that the receivers and services still get terminated and I have confirmed that by testing it myself.
There are some spend tracking apps out there that still do track the incoming sms regardless of the situation.
Would appreciate any inputs on the situation.
Thanks.
Logo puzzle I made for Laracon
Programing Coderfunda March 06, 2024 No comments
https://preview.redd.it/mdeyzgg68smc1.jpg?width=1201&format=pjpg&auto=webp&s=6cb85cacca07a36125d7ee6b8db1f588f651bb01 submitted by /u/jeffjohnvol
[link] [comments]
Query Builder whereAll() and whereAny() Methods Added to Laravel 10.47
Programing Coderfunda March 06, 2024 No comments
The Laravel team released v10.47 this week, which added the whereAll and whereAny methods to the query builder, the ability to use sorting flags with the Collection sortByMany method, and more.
This week will likely be the last release to the 10.x branch before Laravel 11’s release on Tuesday, March 12th, 2024. Laravel 10 will continue to receive bug fixes until August 6th, 2024, and security fixes until February 4th, 2025.
New whereAll and whereAny query builder methods
@musiermoore contributed a new whereAll and whereAny methods to the query builder, along with orWhereAll and orWhereAny methods. These new methods can search against multiple columns using or or and logic
// Before using `orWhere`
User::query()
->where(function ($query) use ($search) {
$query
->where('first_name', 'LIKE', $search)
->orWhere('last_name', 'LIKE', $search)
->orWhere('email', 'LIKE', $search)
->orWhere('phone', 'LIKE', $search);
});
// Using `whereAny`
User::whereAny(
[
'first_name',
'last_name',
'email',
'phone'
],
'LIKE',
"%$search%"
);
Here’s an example of using whereAll, in which all columns would need to match using AND:
$search = 'test';
User::whereAll([
'first_name',
'last_name',
'email',
], 'LIKE', "%$search%");
/*
SELECT * FROM "users" WHERE (
"first_name" LIKE "%test%"
AND "last_name" LIKE "%test%"
AND "email" LIKE "%test%"
)
*/
You can combine multiple like this using orWhereAll and orWhereAny methods.
Support Sort Option Flags on sortByMany Collections
Tim Withers contributed the ability to pass multiple sorting options to the Collection sortBy method. Before this update, you could accomplish this using multiple callables, but using PHP’s sorting flags:
// Pull Request before example
$this->campaigns = $campaigns
->with('folder', 'campaignCategory')
->get()
->sortBy([
fn ($a, $b) => str($a->folder?->name)->lower() str($b->folder?->name)->lower(),
fn ($a, $b) => str($a->campaignCategory->name)->lower() str($b->campaignCategory->name)->lower(),
fn ($a, $b) => str($a->name)->lower() str($b->name)->lower(),
])
// Using sorting flags
$this->campaigns = $campaigns
->with('folder', 'campaignCategory')
->get()
->sortBy(['folder.name', 'campaignCategory.name', 'name'], SORT_NATURAL | SORT_FLAG_CASE)
You can learn more about sorting flags from the sort function in the PHP manual.
Set $failOnTimeout on Queue Listeners
Saeed Hosseini contributed the ability to set the $failOnTimeout property on the queue job that indicates if the job should fail if the timeout is exceeded:
class UpdateSearchIndex implements ShouldQueue
{
public $failOnTimeout = false;
}
Release notes
You can see the complete list of new features and updates below and the diff between 10.46.0 and 10.47.0 on GitHub. The following release notes are directly from the changelog:
v10.47.0
* [10.x] Allow for relation key to be an enum by @AJenbo in
https://github.com/laravel/framework/pull/50311
/>
* Fix for "empty" strings passed to Str::apa() by @tiagof in
https://github.com/laravel/framework/pull/50335
/>
* [10.x] Fixed header mail text component to not use markdown by @dmyers in
https://github.com/laravel/framework/pull/50332
/>
* [10.x] Add test for the "empty strings in Str::apa()" fix by @osbre in
https://github.com/laravel/framework/pull/50340
/>
* [10.x] Fix the cache cannot expire cache with 0 TTL by @kayw-geek in
https://github.com/laravel/framework/pull/50359
/>
* [10.x] Add fail on timeout to queue listener by @saeedhosseiinii in
https://github.com/laravel/framework/pull/50352
/>
* [10.x] Support sort option flags on sortByMany Collections by @TWithers in
https://github.com/laravel/framework/pull/50269
/>
* [10.x] Add whereAll and whereAny methods to the query builder by @musiermoore in
https://github.com/laravel/framework/pull/50344
/>
* [10.x] Adds Reverb broadcasting driver by @joedixon in
https://github.com/laravel/framework/pull/50088
/>
The post Query Builder whereAll() and whereAny() Methods Added to Laravel 10.47 appeared first on Laravel News.
Join the Laravel Newsletter to get Laravel articles like this directly in your inbox.
compare file's date bash
Programing Coderfunda March 06, 2024 No comments
05 March, 2024
Cannot get TRUE when assigning report URL Param to a field
Programing Coderfunda March 05, 2024 No comments
Running Python code in Docker gives: "/usr/bin/python3: can't find '__main__' module in 'test.py'"
Programing Coderfunda March 05, 2024 No comments
FROM ubuntu:latest
RUN apt update
RUN apt install software-properties-common -y
RUN add-apt-repository ppa:deadsnakes/ppa
RUN apt install python3-pip -y
RUN apt-get remove swig
RUN apt-get install swig3.0
RUN ln -s /usr/bin/swig3.0 /usr/bin/swig
RUN pip3 install auto-sklearn
# During debugging, this entry point will be overridden. For more information, please refer to
https://aka.ms/vscode-docker-python-debug
/> ADD . /test.py
WORKDIR /
CMD ["python3", "test.py"]
and I get the error "/usr/bin/python3: can't find 'main' module in 'test.py'" from Docker Desktop. There are other posts similar to this on Stack Overflow, but I made the appropriate changes and it still doesn't seem to work. My Python code is quite simple
import pandas as pd
import autosklearn.classification as classification
import sklearn.model_selection as model_selection
if __name__ == "__main__":
def split_train_val(self, X: pd.DataFrame, y: pd.DataFrame):
X_train, X_val, y_train, y_val = model_selection.train_test_split(
X, y, test_size=0.25)
return X_train, X_val, y_train.to_frame(), y_val.to_frame()
model = classification.AutoSklearnClassifier(
time_left_for_this_task=3600,
ensemble_size=1,
ensemble_nbest=1,
)
dataset = pd.read_csv('data.csv')
dataset = dataset.iloc[:100]
X, y = dataset.drop(columns=[target_col]), dataset[target_col]
self.model.fit(X, y)
print(self.model.cv_results_)
Laravel Validation Provider Package
Programing Coderfunda March 05, 2024 No comments
The Evolution of the Laravel Welcome Page
Programing Coderfunda March 05, 2024 No comments
The release of Laravel 11 and Laravel Reverb will happen on Tuesday, March 12, 2024. Along with major updates to Laravel, we'll get a new welcome page when creating a new Laravel application with laravel new or composer.
I thought it would be fun to see how the welcome page has evolved over previous versions of Laravel. Whether you are new to the framework or have been around a while, there's something special about creating a new Laravel project and seeing that welcome screen!
Laravel 11
Laravel 11 will feature a light and dark theme, which looks gorgeous and inviting. It has a vibrant background, clean icons, and a welcoming feel that inspires creativity:
Laravel 11 welcome page (dark mode)
Laravel 11 welcome page (light mode)
Comparing Laravel 11 (top) to Laravel 10 (bottom)
Laravel 10
It's hard to believe that Laravel 10 was released a year ago on February 14, 2023. Over the last year, we've received countless amazing new features and quality-of-life updates. Here's what the welcome page looks like with a fresh Laravel 10 installation:
Laravel 10 welcome (dark mode)
Laravel 10 welcome (light mode)
Notably, the Laravel logo is centered and is only the logo mark. Laravel 9 and 8 had a left-aligned logo + Laravel text mark:
Logo mark changes between Laravel 8 and Laravel 10
Laravel 8
The welcome page featured in Laravel 8 was the first time we saw a significant change since Laravel 5.x. Laravel 8 was released on September 8, 2020, during the period of time Laravel released a major version every six months:
Laravel 8 dark mode featuring updated Laravel branding
Laravel 8 light mode featuring updated Laravel branding
Laravel's branding was technically updated around the Laravel 6 release. However, Laravel 8 was the first time the new logo was introduced on the welcome page. It featured four main areas/links: documentation, Laravel News, Laracasts, and prominent ecosystem links.
Laravel 5.5
Between Laravel 6 and 7, we didn't see any significant changes to the welcome page, but at some point in the 5.x releases, the welcome page included links to documentation, Laracasts, Laravel News, Forge, and GitHub:
Laravel 5.5 welcome page
Laravel 5.0
Laravel 5.0's landing page had the words "Laravel 5" and rendered a random inspiring quote using the Inspiring facade:
Laravel 5
{{ Inspiring::quote() }}
Laravel 5.0 welcome page
Bonus: Laravel 4.2
Laravel 4.2 had a minimal welcome page featuring a nostalgic logo (base64 image) and folder structure, which included this hello.php file, with the text, "You have arrived."
Laravel 4.2 hello page
The post The Evolution of the Laravel Welcome Page appeared first on Laravel News.
Join the Laravel Newsletter to get Laravel articles like this directly in your inbox.
Laravel 11 + Laravel Reverb will be released on Tuesday, March 12th.
Programing Coderfunda March 05, 2024 No comments
04 March, 2024
My page won't load despite routes on Flask pointing to the right .html code
Programing Coderfunda March 04, 2024 No comments
I am trying to make my index open a page (lessonplan.html) after hitting a button.
`This is the captions route on my deployed website:
@app.route('/captions', methods=['GET']) def captions(): global transcript_text, lesson # Declare transcript_text as a global variable youtube_link = request.args.get('youtube_link')
if youtube_link:
transcript_list = get_youtube_transcript(youtube_link)
transcript_text = ' '.join([item['text'] for item in transcript_list])
try:
openai.api_key = os.getenv("sk-xxx")
lesson_title, lesson = generate_lesson(transcript_text)
except Exception as e:
lesson_title = "Lesson Title Generation Error"
lesson = f"Error generating lesson: {str(e)}"
qr_code_filename = generate_qr_code(youtube_link)
return render_template('lessonplan.html', youtube_link=youtube_link, lesson_title=lesson_title, lesson=lesson, qr_code=qr_code_filename)
Now, this is my index:
Guide Maker body { font-family: 'Arial', sans-serif; background-color: #f4f4f4; margin: 0; padding: 0; display: flex; justify-content: center; align-items: center; height: 100vh; }
.container {
background-color: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
text-align: center;
}
h1 {
color: #333;
}
form {
display: flex;
flex-direction: column;
align-items: center;
}
label {
margin-top: 10px;
font-weight: bold;
color: #555;
}
input, select {
width: 100%;
padding: 8px;
margin-top: 5px;
box-sizing: border-box;
border: 1px solid #ccc;
border-radius: 4px;
}
button {
background-color: #007bff;
color: #fff;
padding: 10px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
margin-top: 15px;
}
button:hover {
background-color: #0056b3;
}
Welcome to the Guide Maker
Enter YouTube Link: Get Captions
And my lessonpage.html whch should open up as I hit the button
Lesson Generated
{{ lesson_title }}
Watch the video here:
{{ lesson | safe }}
Send
function sendMessage() {
// Your JavaScript code for sendMessage
}
// Rest of your JavaScript code...
Download PDF
Go Back
Instead of opening up, I just get:
http://website.xyz/%7B%7B%20url_for('captions')%20%7D%7D 404 (Not Found).
My folder structure is correct. When I deploy this locally, I have no problem whatsoever.
FilamentPHP and Socialite
Programing Coderfunda March 04, 2024 No comments
If not, even if you've used just Socialite I'm interested in your experience as it will be my first time using it. submitted by /u/acjshook
[link] [comments]
Phone Number Formatting, Validation, and Model Casts in Laravel
Programing Coderfunda March 04, 2024 No comments
VS Code Extension for API Insights
Programing Coderfunda March 04, 2024 No comments
Recently, at Treblle, we released a Visual Studio Code extension to work with our free developer tool, API Insights. After releasing this new tool, we wanted to look for ways developers building OpenAPI Specifications could benefit without stopping what they were doing.
So, for those who need to be made aware, API Insights is a free developer tool we created at Treblle that lets you get insights into your API design. It will score your OpenAPI Specification against:
* Performance
* Quality
* Security
The way this works is that we analyze your specification to understand what this API does. We then compare your API to a set of industry standards for APIs and see how close you are to having an "industry standard API".
However, we go a step further than just analyzing your specification; we send a request to the first endpoint that could be successful and measure load time and response size. We can analyze something similar to understand your API better.
The VS Code extension will allow you to analyze your specifications without leaving your editor. Even better, though, is that it will then watch this file for changes and prompt you to re-run the analysis if a change is detected.
We wrote about this new free tool in a little more detail on our blog and would love to hear your thoughts about the extension - also, what developer tool you would find helpful! You never know; we may build it.
The post VS Code Extension for API Insights appeared first on Laravel News.
Join the Laravel Newsletter to get Laravel articles like this directly in your inbox.
Phone Number Formatting, Validation, and Model Casts in Laravel
Programing Coderfunda March 04, 2024 No comments
The Laravel-Phone package makes working with phone numbers in PHP and Laravel a breeze, offering validation rules, attribute casting, utility helpers, and more.
Have you ever built validation around phone numbers that supports multiple countries? This package has helpful validation rules built in, which makes it easy to validate numbers for any country. You can specify acceptible country code formats, but at the same time accept valid "international" numbers:
// Validate either USA or Belguim
Validator::make($request->all(), [
'phone_number' => 'phone:US,BE',
]);
// Validate US specifically, but also accept other countries
Validator::make($request->all(), [
'phone_number' => 'phone:US,INTERNATIONAL',
]);
// Use the Phone rule
Validator::make($request->all(), [
'phone_number' => (new Phone)->country(['US', 'BE']),
]);
// Match country code against another data field
Validator::make($request->all(), [
'phone_number' => (new Phone)->countryField('custom_country_field'),
'custom_country_field' => 'required_with:phone_number',
]);
This package uses the PHP port of Google's phone number handling library under the hood, which has robust parsing, formatting, and validation capabilities for working with phone numbers in PHP:
// Formatting examples
$phone = new PhoneNumber('012/34.56.78', 'BE');
$phone->format($format); // Custom formatting
$phone->formatE164(); // +3212345678
$phone->formatInternational(); // +32 12 34 56 78
$phone->formatRFC3966(); // +32-12-34-56-78
$phone->formatNational(); // 012 34 56 78
You can learn more about this package, get full installation instructions, and view the source code on GitHub. I recommend getting started with the readme for full documentation about this package.
The post Phone Number Formatting, Validation, and Model Casts in Laravel appeared first on Laravel News.
Join the Laravel Newsletter to get Laravel articles like this directly in your inbox.
03 March, 2024
Error: formControlName must be used with a parent formGroup directive. You'll want to add a formGroup directive - Angular reactive forms
Programing Coderfunda March 03, 2024 No comments
First Name*
Then in my component I have:
@Component({
selector: 'guest-input',
templateUrl: './guest-input.component.html',
})
export class GuestInputComponent implements OnInit {
@Input()
guest: Guest;
guestForm: FormGroup;
constructor(private _fb: FormBuilder) { }
ngOnInit() {
this.guestForm = this._fb.group({
firstname: ['test', [Validators.required, Validators.minLength(3)]]
});
}
}
This all looks fine to me but for some reason I am getting:
Error: Uncaught (in promise): Error: formControlName must be used with a parent formGroup directive. You'll want to add a formGroup
directive and pass it an existing FormGroup instance (you can create one in your class).
I thought I had declared this in my .
Weekly /r/Laravel Help Thread
Programing Coderfunda March 03, 2024 No comments
* What steps have you taken so far?
* What have you tried from the documentation?
* Did you provide any error messages you are getting?
* Are you able to provide instructions to replicate the issue?
* Did you provide a code example?
* Please don't post a screenshot of your code. Use the code block in the Reddit text editor and ensure it's formatted correctly.
For more immediate support, you can ask in the official Laravel Discord.
Thanks and welcome to the /r/Laravel community! submitted by /u/AutoModerator
[link] [comments]
How to add variation stock status to Woocommerce product variation dropdown
Programing Coderfunda March 03, 2024 No comments
// Updated Woocommerce Product Variation Select
if ( ! function_exists( 'wc_dropdown_variation_attribute_options' ) ) {
/**
* Output a list of variation attributes for use in the cart forms.
*
* @param array $args
* @since 2.4.0
*/
/*
function wc_dropdown_variation_attribute_options( $args = array() ) {
$args = wp_parse_args( apply_filters( 'woocommerce_dropdown_variation_attribute_options_args', $args ), array(
'options' => false,
'attribute' => false,
'product' => false,
'selected' => false,
'name' => '',
'id' => '',
'class' => '',
'show_option_none' => __( 'Choose an option', 'woocommerce' ),
) );
$options = $args['options'];
$product = $args['product'];
$attribute = $args['attribute'];
$name = $args['name'] ? $args['name'] : 'attribute_' . sanitize_title( $attribute );
$id = $args['id'] ? $args['id'] : sanitize_title( $attribute );
$class = $args['class'];
$show_option_none = $args['show_option_none'] ? true : false;
$show_option_none_text = $args['show_option_none'] ? $args['show_option_none'] : __( 'Choose an option', 'woocommerce' ); // We'll do our best to hide the placeholder, but we'll need to show something when resetting options.
if ( empty( $options ) && ! empty( $product ) && ! empty( $attribute ) ) {
$attributes = $product->get_variation_attributes();
$options = $attributes[ $attribute ];
}
$html = '';
$html .= '' . esc_html( $show_option_none_text ) . '';
if ( ! empty( $options ) ) {
if ( $product && taxonomy_exists( $attribute ) ) {
// Get terms if this is a taxonomy - ordered. We need the names too.
$terms = wc_get_product_terms( $product->get_id(), $attribute, array( 'fields' => 'all' ) );
foreach ( $terms as $term ) {
if ( in_array( $term->slug, $options ) ) {
$html .= 'slug ) . '" ' . selected( sanitize_title( $args['selected'] ), $term->slug, false ) . '>' . esc_html( apply_filters( 'woocommerce_variation_option_name', $term->name ) ) . ' ';
}
}
} else {
foreach ( $options as $option ) {
// This handles lt 2.4.0 bw compatibility where text attributes were not sanitized.
$selected = sanitize_title( $args['selected'] ) === $args['selected'] ? selected( $args['selected'], sanitize_title( $option ), false ) : selected( $args['selected'], $option, false );
$html .= '' . esc_html( apply_filters( 'woocommerce_variation_option_name', $option ) ) . ' Output Stock Details Here ';
}
}
}
$html .= '';
echo apply_filters( 'woocommerce_dropdown_variation_attribute_options_html', $html, $args );
}
}
I can pull out the stock level for the overall product, but now for each variation.
Any help would be greatly appreciated.
How to get rid of the padding of SF Symbol in SwiftUI
Programing Coderfunda March 03, 2024 No comments
VStack{
Image(systemName: "drop")
.resizable()
.font(.largeTitle.weight(.ultraLight))
.scaledToFit()
}
Screenshot shows a small gap on the right side:
After using additional padding, the image still looks off. That gap becomes less but it's still noticable.
My expectation was that applying .scaledToFit would actually scale the image to fit the screen, and then I could use the padding.
Though even with padding the issue persists:
I tried to use .aspectRatio(contentMode: .fit), and also different aspect ratios hoping that it could fix it.
Also the same issue persists even using the "square" SF Symbol (that likely excludes aspect ratio issue cuz square is 1:1) Though I fixed issue with square using .imageScale(.large)
Square without .imageScale(.large):
Square with .imageScale(.large):
Watch Face isn't recognised as a standalone app by Google Play store
Programing Coderfunda March 03, 2024 No comments
I have set my watch face to be a standalone app (following the instructions from the
https://developer.android.com/training/wearables/apps/standalone-apps) by setting the com.google.android.wearable.standalone meta data in the manifest.xml:
However, for some reason Google Play still thinks that the Wear OS bundle is a non-standalone app (see the "Requires mobile app" message in the screenshot below).
Has anyone experienced a similar issue? Do you guys have any ideas what could be wrong?
02 March, 2024
What's the go to method on doing Auto Scaling with Laravel?
Programing Coderfunda March 02, 2024 No comments
Is there a better way in doing this? I'm mostly looking into making it easier to deploy code updates.
In your work, how do you do auto scaling with Laravel? submitted by /u/mod_suck
[link] [comments]
Why is there a gap to other elements when I add an image to the navigation bar in html?
Programing Coderfunda March 02, 2024 No comments
Here is the HTML file:
DataPredict
Home
Contact
Why DataPredict
And here is the CSS file:
body {
margin: 0px 0px 0px 0px;
}
.top-navigation-bar {
background-color: #5B9BD5;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
width: inherit;
height: 50px;
}
.top-navigation-bar img{
margin: 0px;
padding: 0;
border-width: 0;
width: auto;
height: 100%;
display: inline;
}
.top-navigation-bar button{
border-width: 0px;
margin: 0px;
padding: 0;
background-color: inherit;
padding-block: 0;
width: 10%;
height: 100%;
border-style: none;
display: inline;
}
.top-navigation-bar button text{
padding: 0;
height: 100%;
width: 95%;
background-color: inherit;
display: inline;
}
.top-navigation-bar button selected{
padding: 0;
height: 90%;
width: 5%;
background-color: inherit;
display: inline;
}
.top-navigation-bar button:hover selected{
padding: 0px 0px 0px 0px;
height: 90%;
width: 5%;
background-color: black;
display: inline;
}
Ah also, I was trying to make a black bar appear when the mouse hovers over it. So don't change that. But also I could not get that to work either, since it isn't appearing when I hover it. What exactly I'm missing here?
Drop down menu with protected sheet
Programing Coderfunda March 02, 2024 No comments
I have a little file Excel.
This file has protected sheets with drop down menu and these are the steps:
1)double click to show Userform1;
2)click on CommandButton of the Userform to write on the protected sheet:
Private Sub CommandButton1_Click()
ActiveSheet.Unprotect Password:="password"
Range("a1") = "prova"
ActiveSheet.Protect Password:="password", DrawingObjects:=True
Unload Me
End Sub
The problem is that when I fix manually protected sheets, double click on cells with drop down menu does work, but after I execute the "Private Sub CommandButton1_Click()" procedure, drop down menu doesn't work any more.
Is it possible to force drop down menu to work also after I execute the procedure triggered by CommandButton1?
I need Userform1 to show after double-click event, also for the cells formatted with the drop down menu.
Thank you in advance
I tried changing parameters of the Protect Method, but with the same result.