when I update some columns of the table it insert new field in table
"id": 1,
"invoice_id": "0001-2019-20",
"client_id": "1",
"currency_id": "4",
"date": "2019-06-06",
"subject": "wordpress",
"total": "3000"
when i update only subject and total it will insert new field
"id": 2,
"invoice_id": "",
"client_id": "0",
"currency_id": "0",
"date": "0000-00-00",
"subject": "OMS",
"total": "0"
here is my controller,
$invoices = new Invoice;
$invoices->client_id = $request->get('client_id');
$invoices->currency_id = $request->get('currency_id');;
$invoices->subject = $request->get('subject');
$invoices->save();
The code you are using is for creating a new record.
However you are almost there.
So let's say you want to update below data
{"id": 1,
"invoice_id": "0001-2019-20",
"client_id": "1",
"currency_id": "4",
"date": "2019-06-06",
"subject": "wordpress",
"total": "3000"}
Use Below Code to update that row.
$invoices = Invoice::find($request->get('id'));
$invoices->client_id = $request->get('client_id');
$invoices->currency_id = $request->get('currency_id');
$invoices->subject = $request->get('subject');
$invoices->save();
There are alternative method as below.
$invoices = Invoice::find($request->get('id'));
$invoices->update([
'client_id' => $request->get('client_id'),
'currency_id' => $request->get('currency_id'),
'subject' => $request->get('subject')
]);
Note: For above method array key names and your table column names
must be same.
I have a document indexed whose structure is as follows:
{
"_index": "yelp",
"_type": "user",
"_id": "ABC",
"_score": 1,
"_source": {
"yelping_since": "2007-07",
"votes": {},
"review_count": 1798,
"name": "TEST_USER",
"user_id": "123",
"friends": [],
"fans": 89,
"average_stars": 3.48,
"type": "user",
"compliments": {},
"elite": []
}
}
When I do:
myFilter = TermFilter("_id", "ABC")
q = FilteredQuery(MatchAllQuery(), myFilter).search()
results = conn.search(query=q, indices=index_name,type=doc_typeU)
Exact result is displayed.
But when I try to search for field say user_id as follows,
myFilter = TermFilter("user_id", "123")
q = FilteredQuery(MatchAllQuery(), myFilter).search()
results = conn.search(query=q, indices=index_name,type=doc_typeU)
No results are displayed. Any idea why?
please try this one
myFilter = TermQuery("user_id", "123")
q = FilteredQuery(MatchAllQuery(), myFilter).search()
results = conn.search(query=q, indices=index_name,type=doc_typeU)
I have seen a few questions on here (one was even by me) with respect to using R to plot an image.
The difference here is that I need to set the reference cooridnates for my image to match the data I am looking to plot on top of the image.
More specifically, I need R to understand that the coordinates for the background image are x = (-100,100) and y = (40,-40).
I have been able to to read in the image file and plot it using the ReadImages package, but when I overlay my data using points(), the data obviously do not line up appropriately.
Any help is much appreciated.
EDIT: here are some example data and I attached the image:
structure(list(teamid = c("6", "6", "6", "6", "6", "6", "2",
"6", "6", "6", "2", "6", "10", "10", "10", "10", "20", "20",
"10", "10", "10", "20", "20", "20", "10", "10"), xcoord = c("79",
"81", "33", "34", "75", "52", "-67", "80", "44", "79", "-53",
"54", "-55", "-81", "-66", "-66", "45", "81", "-78", "-70", "-59",
"50", "53", "63", "-79", "-78"), ycoord = c("0", "0", "-18",
"-20", "6", "-11", "-7", "7", "-28", "-10", "35", "22", "25",
"-5", "25", "23", "-11", "13", "22", "16", "13", "23", "7", "16",
"8", "8")), .Names = c("teamid", "xcoord", "ycoord"), class = "data.frame", row.names = c(74328L,
74331L, 74332L, 74334L, 74336L, 74338L, 74340L, 74341L, 74346L,
74347L, 74348L, 74349L, 100136L, 100137L, 100138L, 100139L, 100147L,
100148L, 100151L, 100154L, 100156L, 100158L, 100159L, 100161L,
100163L, 100167L))
You can create an empty plot with the correct dimensions, then use the rasterImage function to plot the image, then adding the points should work fine.
Another approach is to use the updateusr function from the TeachingDemos package after plotting the image to make sure that the coordinates match what you want them to before adding lines or points.
I saved your graphic above as ice.png and ran the following code:
library(EBImage)
ice <- readImage('My Pictures/ice.png')
pos <- structure(list(teamid = c("6", "6", "6", "6", "6", "6", "2",
"6", "6", "6", "2", "6", "10", "10", "10", "10", "20", "20",
"10", "10", "10", "20", "20", "20", "10", "10"), xcoord = c("79",
"81", "33", "34", "75", "52", "-67", "80", "44", "79", "-53",
"54", "-55", "-81", "-66", "-66", "45", "81", "-78", "-70", "-59",
"50", "53", "63", "-79", "-78"), ycoord = c("0", "0", "-18",
"-20", "6", "-11", "-7", "7", "-28", "-10", "35", "22", "25",
"-5", "25", "23", "-11", "13", "22", "16", "13", "23", "7", "16",
"8", "8")), .Names = c("teamid", "xcoord", "ycoord"),
class = "data.frame", row.names = c(74328L,
74331L, 74332L, 74334L, 74336L, 74338L, 74340L, 74341L, 74346L,
74347L, 74348L, 74349L, 100136L, 100137L, 100138L, 100139L, 100147L,
100148L, 100151L, 100154L, 100156L, 100158L, 100159L, 100161L,
100163L, 100167L))
pos$xcoord <- as.numeric(pos$xcoord)
pos$ycoord <- as.numeric(pos$ycoord)
ice2 <- as.raster(ice)
pin <- par('pin')
plot( c(-100,100), c(-40,40), type='n', xlab='', ylab='',
asp=pin[1]/pin[2], axes=FALSE, xaxs='i', yaxs='i')
rasterImage(ice2, -100, -40, 100, 40, interpolate=FALSE)
with(pos, text(xcoord, ycoord, teamid, col='green', cex=1.2) )
Does this do what you want?