Using Email Body and Attachment at a time
My Code is:
Mail::send( [],array(), function ($message) use ($fromName,$fromEmail,$receiptEmailSubject,$receiptEmailData,$emilId,$pdf){
$message->to($emilId)
->from($fromEmail,$fromName)
->subject($receiptEmailSubject)
->setBody($receiptEmailData, 'text/html')
->attachData($pdf->output(), 'receipt.pdf',['mime' => 'application/pdf']);
});
But unable to use "setBody" and "attachData" as like. (If removed any one email sending works Properly. Need to remove "setBody" OR "attachData")
How to use "setBody" and "attachData" together ?
You can't use setBody and attachData together in Laravel
Related
I want to chained alerts via json. I have this:
[
{"mes":"there are <strong>3<\/strong> messages.", "ico":"info"},
{"mes":"message1","ico":"error"},
{"mes":"message2","ico":"success"}
{"mes":"message3","ico":"warning"}
]
I want to generate 4 alerts for this json one after another. I tried with jquery.each but no success.
Please help.
that was ridiculously easy.
i sent data from php like this:
echo json_encode([
{"mes":"there are <strong>3<\/strong> messages.", "ico":"info"},
{"mes":"message1","ico":"error"},
{"mes":"message2","ico":"success"}
{"mes":"message3","ico":"warning"}
]);
and parse like this:
swal.queue(JSON.parse(data);
so i achieved what i want.
I have a m.request call like this:
mCmdName = "cn:cmd:list:deselectAll";
m.request({
method : "POST",
url : "/testing/cmd/" + mCmdName,
data: data
});
Now m.request calls
xhrOptions.url = parameterizeUrl(xhrOptions.url, xhrOptions.data);
and tries to replace all ':[name]' parts with data[name] which results in 'undefined' as data doesn't contain any of the keys. Data is just the data object of the XHR request.
Is there a way to prohibit this default behavior?
Thanks, Stefan
PS: I'm asking here and not in mithril mailing list because I can't post there for incomprehensible reasons. Maybe somebody can give me a hint on this.
Have you tried
encodeURIComponent("cn:cmd:list:deselectAll")
which gives you
cn%3Acmd%3Alist%3AdeselectAll
If necessary you can decode on the server.
var myArray = [1,2,3,4];
If I post to 'api/myArray' and I want to retrieve these values, the following does not work:
'api/:var'
field : {blah: req.params.var[0], blah2: req.params.var[1]}
This does not work, and after console I realized it is no longer an array. Instead, var is now 1,2,3,4 instead of [1,2,3,4]. How do I solve this?
My excuses. I should really have tried harder to find out how to do this.
req.params.var.split(',') would do this
1st:
while sending you can serialize it
JSON.stringify(var)
and recieve it as
JSON.parse(var)
2nd:
Post with formdata instead
you can use req.body instead of params
then you can access like
req.body.var[0]
I was wondering how I would go about checking to see if a table contains a value in a certain column.
I need to check if the column 'e-mail' contains an e-mail someone is trying to register with, and if something exists, do nothing, however, if nothing exists, insert the data into the database.
All I need to do is check if the e-mail column contains the value the user is registering with.
I'm using the RedBeanPHP ORM, I can do this without using it but I need to use that for program guidelines.
I've tried finding them but if they don't exist it returns an error within the redbean PHP file. Here's the error:Fatal error: Call to a member function find() on a non-object in /home/aeterna/www/user/rb.php on line 2433
Here's the code that I'm using when trying this:
function searchDatabase($email) {
return R::findOne('users', 'email LIKE "' . $email . '"');
}
My approach on the function would be
function searchDatabase($email) {
$data = array('email' => $email);
$user = R::findOne('users', 'email LIKE :email, $data);
if (!empty($user)) {
// do stuff here
} // end if
} // end function
It's a bit more clean and in your function
Seems like you are not connected to a database.
Have you done R::setup() before R::find()?
RedBeanPHP raises this error if it can't find the R::$redbean instance, the facade static functions just route calls to the $redbean object (to hide all object oriented fuzzyness for people who dont like that sort of thing).
However you need to bootstrap the facade using R::setup(). Normally you can start using RB with just two lines:
require('rb.php'); //cant make this any simpler :(
R::setup(); //this could be done in rb.php but people would not like that ;)
//and then go...
R::find( ... );
I recommend to check whether the $redbean object is available or whether for some reason the code flow has skipped the R::setup() boostrap method.
Edited to account for your updated question:
According to the error message, the error is happening inside the function find() in rb.php on line 2433. I'm guessing that rb.php is the RedBean package.
Make sure you've included rb.php in your script and set up your database, according to the instructions in the RedBean Manual.
As a starting point, look at what it's trying to do on line 2433 in rb.php. It appears to be calling a method on an invalid object. Figure out where that object is being created and why it's invalid. Maybe the find function was supplied with bad parameters.
Feel free to update your question by pasting the entirety of the find() function in rb.php and please indicate which line is 2433. If the function is too lengthy, you can paste it on a site like pastebin.com and link to it from here.
Your error sounds like you haven't done R::setup() yet.
My approach to performing the check you want would be something like this:
$count = count(R::find('users', 'email LIKE :email', array(':email' => $email)));
if($count === 0)
{
$user = R::dispense('users');
$user->name = $name;
$user->email = $email;
$user->dob = $dob;
R::store($user);
}
I don't know if it is this basic or not, but with SQL (using PHP for variables), a query could look like
$lookup = 'customerID';
$result = mysql_fetch_array(mysql_query("SELECT columnName IN tableName WHERE id='".$lookup."' LIMIT 1"));
$exists = is_null($result['columnName'])?false:true;
If you're just trying to find a single value in a database, you should always limit your result to 1, that way, if it is found in the first record, your query will stop.
Hope this helps
I am sending an array from jquery via the url requerts to the rails controller.
when I do this in my controller
log_array = (params[:log_ids])
logger.debug "This is the array #{log_array.to_a}"
I get this in my server log
This is the array 85,84,83,82
I am trying this query to get all the selected logs:
#logs = Log.where(['"logs"."id" IN (?)', log_array])
I get this on the server log
SELECT "logs".* FROM "logs" WHERE ("logs"."id" IN ('85,84,83,82'))
It sould be like this
SELECT "logs".* FROM "logs" WHERE ("logs"."id" IN (85,84,83,82))
It seems like it puts the arry in like a string.
Is there any way to make the sql right for an array?
You're making things too SQL-ish. Try this:
Log.find_all(params[:log_ids])
Or Log.where(:id => params[:log_ids]) if you want to use where() goodness.
Would use the .where listed below...check out the link to the rails 3.1 deprecations.
http://m.onkey.org/active-record-query-interface