Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
We want to connect the people who have knowledge to the people who need it, to bring together people with different perspectives so they can understand each other better, and to empower everyone to share their knowledge.
Robert Niro
Laravel file() to store files https://laravel.com/docs/5.4/requests#files
Store the
$path
to your DB$path = $request->photo->store('logo');
the
$request->photo
is depending on your input file attribute name. In your case, it should be$request->img.
the above code will create a folder (if not exist), namely “logo” and store to that folder with a random string file name.
Also check your configuration for file, located at /config/filesystem.php. Default is set to public
Use asset function to get the full path from the public folder
Robert Niro
As @lagbox tried to highlight in a comment, for pivot tables, both relationships should be belongsToMany. Inverse of hasMany is belongsTo.
If one article belongs to many categories, and one category can have many articles, then, ideally, there it should be a many-to-many relationship. The category model should have a
belongsToMany
relationship with Article model and vice versa. Additionally, there should be a pivot table,article_category
. And as many have suggested, you can get articles the belongs to a category by using@foreach($category->articles as $articles)
Robert Niro
An easy way to disable/hide the topup form is by copying the “Account Funds” template (myaccount/account-funds.php) from the plugin folder to your theme folder — i.e. copy this file:
wp-content/plugins/woocommerce-account-funds/templates/myaccount/account-funds.php
to:
wp-content/themes/your-theme/woocommerce/myaccount/account-funds.php
And then find and change the following:
to:
See full code here. (for “WooCommerce Account Funds” version 2.1.16)
You could also instead edit the topup form template itself (myaccount/topup-form.php) like this.
And I’d also add this to the theme functions file:
// If the user is a "customer", bypass the action which handles top-ups.
add_action( 'wp', function(){
if ( isset( $_POST['wc_account_funds_topup'] ) && current_user_can( 'customer' ) ) {
unset( $_POST['wc_account_funds_topup'] );
}
}, 0 );
Robert Niro
By setting the $assoc parameter to json_decode to true, we can convert the JSON values into arrays rather than objects, and then iterate through the product_id array, finding matching quantities from the second array:
$j1 = ‘{“1″:”9″,”3″:”7″,”4″:”6″,”5″:”10″,”6″:”8”}’;
$j2 = ‘{“1″:”1″,”2″:”1″,”3″:”1″,”4″:”1″,”5″:”1″,”6″:”7”}’;
$array1 = json_decode($j1, true);
$array2 = json_decode($j2, true);
foreach ($array1 as $key => $product_id) {
$quantity = $array2[$key] ?? 0;
echo “Product $product_id: Quantity: $quantity\n”;
}
By setting the $assoc parameter to json_decode to true, we can convert the JSON values into arrays rather than objects, and then iterate through the product_id array, finding matching quantities from the second array:
$j1 = ‘{“1″:”9″,”3″:”7″,”4″:”6″,”5″:”10″,”6″:”8”}’;
$j2 = ‘{“1″:”1″,”2″:”1″,”3″:”1″,”4″:”1″,”5″:”1″,”6″:”7”}’;
$array1 = json_decode($j1, true);
$array2 = json_decode($j2, true);
foreach ($array1 as $key => $product_id) {
$quantity = $array2[$key] ?? 0;
echo “Product $product_id: Quantity: $quantity\n”;
}
Output:
Product 9: Quantity: 1
Product 7: Quantity: 1
Product 6: Quantity: 1
Product 10: Quantity: 1
Product 8: Quantity: 7
Robert Niro
I had the same issue and I fixed it by using the autoRegenerate option:
Configure::write(
‘Session’,
array(
‘defaults’ => ‘cake’,
‘timeout’ => ’30’,
‘autoRegenerate’ => true
)
);
Robert Niro
I’ve done this using a quick addition to the before filter() in my app_controller.php file.
function beforeFilter() {
if ($this->RequestHandler->isMobile()) {
$this->is_mobile = true;
$this->set(‘is_mobile’, true );
$this->autoRender = false;
}
}
Robert Niro
Hello,
I’m not sure I completely understand the question but il try to answer it.
It sounds like you are trying to get authentication from one app to the next to retrieve information about the initial login. One way this can be done is by using something to know as SAML. SAML stands for security assertion markup language and is a way of exchanging authentication between two parties or different sites. This would need to be implemented in both apps in order to work. WordPress has plugins that support this functionality, I had a quick google and I found mini orange. Larvel also has libraries that support this. I hope this points you in the right direction.
Robert Niro
Maybe this helps:
new_data = fake_data.columnA.str.split('',n=4, expand=True).drop(0, axis=1)
stats = new_data.apply(pd.Series.value_counts)
stats = stats.apply(lambda x: (x/x.sum())*100).round(2).fillna(0)
print(stats)
Output
1 2 3 4
A 54.54 45.45 0 0
V 0 0 45.45 54.54
X 45.45 54.54 0 0
Y 0 0 54.54 45.45
Robert Niro
I really haven’t found normal example of PHP file where MySQL transactions are being used. Can you show me simple example of that?
And one more question. I’ve already done a lot of programming and didn’t use transactions. Can I put a PHP function or something in header.php that if one mysql_query fails, then the others fail too?
I think I have figured it out, is it right?:
mysql_query(“SET AUTOCOMMIT=0”);
mysql_query(“START TRANSACTION”);
$a1 = mysql_query(“INSERT INTO rarara (l_id) VALUES(‘1’)”);
$a2 = mysql_query(“INSERT INTO rarara (l_id) VALUES(‘2’)”);
if ($a1 and $a2) {
mysql_query(“COMMIT”);
} else {
mysql_query(“ROLLBACK”);
}
Robert Niro
Threading isn’t available in stock PHP, but concurrent programming is possible by using HTTP requests as asynchronous calls.
With the curl’s timeout setting set to 1 and using the same session_id for the processes you want to be associated with each other, you can communicate with session variables as in my example below. With this method you can even close your browser and the concurrent process still exists on the server.
Don’t forget to verify the correct session ID like this:
http://localhost/test/verifysession.php?sessionid=%5Bthe correct id]
startprocess.php
$request = "http://localhost/test/process1.php?sessionid=".$_REQUEST["PHPSESSID"];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $request);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
curl_exec($ch);
curl_close($ch);
echo $_REQUEST["PHPSESSID"];
process1.php
set_time_limit(0);
if ($_REQUEST["sessionid"])
session_id($_REQUEST["sessionid"]);
function checkclose()
{
global $_SESSION;
if ($_SESSION["closesession"])
{
unset($_SESSION["closesession"]);
die();
}
}
while(!$close)
{
session_start();
$_SESSION["test"] = rand();
checkclose();
session_write_close();
sleep(5);
}
verifysession.php
if ($_REQUEST["sessionid"])
session_id($_REQUEST["sessionid"]);
session_start();
var_dump($_SESSION);
closeprocess.php
if ($_REQUEST["sessionid"])
session_id($_REQUEST["sessionid"]);
session_start();
$_SESSION["closesession"] = true;
var_dump($_SESSION);