i want to query whereBetween two dates with time
here is code which is working fine
whereBetween('created_at', [now()->subDay()->format('Y-m-d') . ' ' . $tgame->start_time->format('H:i:s'), now()->format('Y-m-d') . ' ' . $tgame->end_time->format('H:i:s')]
but this code is not working
$date = Carbon::parse($request->date);
whereBetween('created_at', [$date->subDay()->format('Y-m-d') . ' ' . $tgame->start_time->format('H:i:s'), $date->format('Y-m-d') . ' ' . $tgame->end_time->format('H:i:s')]
please also explain thank you
Calling subDay() on the $date object will set the time in the Carbon object back 24 hours. So in the upper boundary for whereBetween, you are not using the request date, but the one 24 hours back.
To achieve what you want, you need to copy the object before changing it:
...->whereBetween('created_at', [$date->copy()->subDay()->format('Y-m-d') . ' ' . $tgame->start_time->format('H:i:s'), $date->format('Y-m-d') . ' ' . $tgame->end_time->format('H:i:s')]
Related
Thanks for the reaching out to my question, but i have got a problem, I'm trying to Import an excel file with multiple sheets.
Find sheets by some cell-value validation, like if on cell E7, i have a value, store this sheet as separate file. I'm doing mapping() for cell values, and then trying to use Excel::store to save each individual sheet separately. Can't receive any data for individual sheets
Also store the original file. This works!
The issue is, i can't receive any data for storing individual-sheets as excel files, i can create the individual excel files, but no data is being received, or maybe i'm not using the right data-format mentioned on documentation.
Please also check the code. Any help would be appreciated.
public function mapping(): array
{
return [
'altafit_id' => 'E7',
'year' => 'B3',
'initial_month' => 'B4',
'final_month' => 'B5',
];
}
public function model(array $row)
{
// dd($row);
$name = $row['altafit_id'];
$year = $row['year'];
$initial_month = $row['initial_month'];
$final_month = $row['final_month'];
$file_type = 'club';
// dd(collect((object) $row));
Excel::store(collect((object) $row), 'P&L_' . $name . '_' . $year . '_' . $initial_month . '_06' . ',clubs' . ',' . $initial_month . ',' . $final_month . '.' . 'xls', 'public');
return new Files([
//'user_id' => $row['user_id'],
'file_name' => 'P&L_' . $name . '_' . $year . '_' . $initial_month . '_06' . ',clubs' . ',' . $initial_month . ',' . $final_month . '.' . 'xls',
'file_type' => $file_type
]);
}
Already check the documentation, but doesn't work for me.
https://docs.laravel-excel.com/3.1/getting-started/
Since around March of this year our osTicket system started posting duplicate tickets and duplicate threads.
I've tried everything method I know of to troubleshoot and identity where and why this is occurring. I've even implemented a catch condition to check the db tables prior to inserting tickets and threads to see if the contents of the $vars[]'s match what is already in the DB tables.
No success to solve this problem whatsoever.
I've Googled it and see where this issue has been in existence and dates back a number of years.
Does any one have a solution on how to stop osTicket from consistently creating ducpliate tickets and threads?
I tried the following from piecing together suggestions others have made out there in the various osTicket up through v1.10. Here is the code I tried. It actually worked for 2-days straight, then began to fail again yesterday.
Inserted around line 2498 in ./include/class.ticket.php right before if($errors) return 0;.
/**
* J.Doe added to intercept duplicate ticket entries.
* Updated: 2017-06-12
* #author John Doe <jd#example.com>
*/
$sql1='
SELECT ticketID FROM ost_ticket
WHERE
source = "' . $vars['source'] . '"
AND topic_id = "' . $vars['topicId'] . '"
AND url = "' . $vars['url'] . '"
AND priority_id = "' . $vars['priorityId'] . '"
AND duedate = "' . date( 'Y-m-d H:i:s', strtotime( $vars['duedate'] . ' ' . $vars['time'] ) ) . '"
AND team_id = "' . $vars['assignId'] . '"
AND subject = "' . $vars['subject'] . '"
AND dept_id = "' . $vars['deptId'] . '"
AND email = "' . $vars['email'] . '"
AND name = "' . $vars['name'] . '"
';
$sql2='
SELECT id FROM ost_ticket_thread
WHERE
staff_id = "' . $vars['assignId'] . '"
AND poster = "' . $vars['name'] . '"
AND title = "' . $vars['subject'] . '"
AND body = "' . $vars['message'] . '"
';
$res1=db_query($sql1);
$res2=db_query($sql2);
if( ( $res1 && db_num_rows( $res1 ) ) || ( $res2 && db_num_rows( $res2 ) ) ) {
header( 'Location: http://example.com/workorders/' );
exit;
}
//Any error above is fatal.
if($errors) return 0;
I'm new in Laravel please me.
I'm working on laravel project which is already done by other developers.
I am stuck in Model::with function.
QxAppDetail::with(['qx_app_translation', 'qx_app_pages.qx_page_translation',
'user_app_info' => function($query) use($device_registration_id) {
$query->where('device_registration_id', $device_registration_id);
}])->selectRaw($this->table . '.app_id, '
. 'if(qx_app_details.app_icon = "", "", CONCAT("' . $this->app_icon_path . '","/", qx_app_details.app_icon)) as app_icon, '
. 'if(qx_app_details.download_link="","",CONCAT("' . $apk_url . '",qx_app_details.download_link)) as download_link,'
. $this->table . '.open_link, qx_app_details.package_name, qx_app_details.qeexo_default_app, qx_app_details.service_id,qx_app_details.sort_order,qx_app_details.is_enabled')
->orderBy('qx_app_details.sort_order', 'ASC')
->whereIn('qx_app_details.device_registration_id', array(0, $device_registration_id))
->get();
in above query i need to concat url with column like
'if(qx_app_details.download_link="","",CONCAT("' . $apk_url . '",qx_app_details.download_link)) as download_link,'
in qx_app_pages. but i'm not able to do this.
qx_app_pages and qx_page_translation are tables
Current Query output is:
[{"app_id":472,"app_icon":"","download_link":"","open_link":"","package_name":"com.android.settings","qeexo_default_app":"0","service_id":"9","sort_order":"0","is_enabled":"1","qx_app_translation":[{"locale":"en_US","app_name":"Settings","app_description":""}],"qx_app_pages":[{"page_id":213,"page_icon":"iVBORw0KGgoAAAANSUhEUgAAAGYAAABmCAMAAAAOARRQAAAApVBMVEX\/\/\/80d+D09PQ1dNb+\/v79\n\/f319fX29vb8\/Pz5+fk1dNg0d94zduAsc98ncd8hb9\/w9f0tcNV0n+n2+fwpbtWJruyxyvOVtu7E\n1vXs8vzj6\/rc5vk1dta1x+iUr+NXjeU7fuJLhuPR3PeApOqsw\/Bgkua+0fTX4fCUs+xumN\/j6fFr\nl+ectOS\/zuvO1+ykwPARad1XhdhBfNd6oeBbjNqHqeJ1neFQlFnoAAAGlElEQVRogb2afV+bPBSG\neQsBSqCU2td1Fm1r1TnndPv+H+1JApS8nITU\/Xzyx+aRmpucKzl3QvG8\/79FtH1l3DaUJAlS4ujz\ncaReh1WST8SRJe5+m6ZposTIHEdqnAIxpIIlldQeRyxGthhLcd8Lxji5MkbmOFKvd5+K4zhxitdr\n03WxV6zEbUtwHKTiXwVBIGUoCLpeo+WB\/oMvcftLFiNz7LWMKJfYoiLG0+Y49VJAxRYjL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_id":"472","qeexo_default_page":"0","is_deleted":"0","qx_page_translation":[{"page_name":"Home","locale":"en_US"}]}],"user_app_info":{"order_id":391,"device_registration_id":"11862","app_id":"472","default_page_id":"213","sort_order":"0","qeexo_default_app":"1","is_enabled":"1"}}]
Thanks in advance.
I have a CSV file with name,area,city fieds and I'm expecting that CSV with following fields name,area,city,latitude,longitude
Can any one suggest which API is best for these,
I already tried
Google API's
Textsearch: this is giving overall city wise. Not particular
eg: kfc, in jp nagar 1st phase, bangalore it throws all over bangalore kfc list
I want exactly
echo $url = "https://maps.googleapis.com/maps/api/geocode/json?address=" . $name1 . "+" . $area1 . "+" . $city . "&key=" . $api_key;
Which API will fulfill my requirement?
I tried this also
$url = "https://maps.googleapis.com/maps/api/place/textsearch/json?query=". $name1 . "+" . $area1 . "+" . $city . "&key=" . $api_key;
Is there a way to adjust the size of gorcery CRUD's list thumbnails?
The way it is now it's just silly big, and breaks the table flow.
If possible, it would be nice to have a PHP solution or grocery CRUD setting for this; if not - a CSS rule would be ok, I guess.
Same issue I came across, I'm sure it's a quick-and-dirty solution but it worked for me.
Open your application/library/Grocery_CRUD.php
Download timthumb from here
Place timthumb.php in Root directory (in same directory
level cache folder should be there)
Find function change_list_value
Find around line number 333 in Grocery_CRUD.php
$file_url_anchor .= 'class="image-thumbnail">';
Replace with... following
$file_url_anchor .= ' class="image-thumbnail"><img src="' . base_url('timthumb.php') . '?src=' . $file_url . '&w=100&h=100&zc=3' .'" height="50px">';
Again Find function get_upload_file_input
Find around line number 2545 in Grocery_CRUD.php
$input .= $is_image ? " $image_class'>" : "' target='_blank'>$value";
Replace with following
$input .= $is_image ? " $image_class'><img src='".base_url('timthumb.php') . '?src=' . $file_url . '&w=100&h=100&zc=3'."' height='50px'>" : "' target='_blank'>$value";
Hope this would help you to get rid of ugly size in your list as well as add/edit forms