I do:
$this->post('/v1/customer', ['area' => 'kil'])
->seeJson(['created' => true]);
But instead of created => true, I would like to do "NOT STATEMENTS".
Ex: parent!=null or created_at > '0000-00-00'
How can this be achieved?
Laravel does have a dontSeeJson function which would solve both of the examples you've listed (though possibly not a more general case) --
$this->dontSeeJson(['parent' => null]);
$this->dontSeeJson(['created_at' => '0000-00-00']);
If you need something more specific, I agree with #gontrollez - decode the json (json_decode($this->response->getContent(), true)) and test that.
Related
Here is a table named stages and below are the fields
I don't want to allow to add the same from and to points example, if points from 1 to 10 is already added means not allow them to add the same range, another one condition is don't allow to add in between points example in-between 1to 10 like 5 to 7 are also not allowed.
Tried laravel query
$isexist = Stage::whereBetween('from', [$request->from, $request->to])
->orWhereBetweenColumn('to','from', [$request->from, $request->to])->exists();
but it not satisfying all conditions.
Any one please help, thanks in advance.
you can validate the data like this
$validator = Validator::make($inputData, [
'label' => 'required|unique:tableName,label'
]);
if($validator->fails()){
//Throw validation errors
}
Or you can use
Model::query()->updateOrCreate(['label' => $request->label], [
'from' => $request->from,
'to' => $request->to
]);
Read more on unique validation reference: https://laravel.com/docs/9.x/validation#quick-writing-the-validation-logic
I use the route-helper ({{ route('routename') }}) in my Blade template files to filter and/or sort the results of the page.
What is the easiest way to attach a parameter to the previous ones?
As an example:
I visit the page /category1 and see some products. Now I use the sorting which changes the URL to /category1?sort_by=title&sort_order=asc
If I use another filtering now, I would like the parameter to be appended to the current one. So to /category1?sort_by=title&sort_order=asc&filter_by=year&year=2017 but the result is only /category1?filter_by=year&year=2017 .
I create the Urls with the route-helper like:
route('category.show', [$category, 'sort_by' => 'title', 'sort_order' => 'asc'])
route('category.show', [$category, 'filter_by' => 'year', 'year' => $year])
You could probably use something like:
$new_parameters = ['filter_by' => 'year', 'year' => $year];
route('category.show', array_merge([$category], request()->all(), $new_parameters]);
to use all previous parameters and add new ones.
Obviously you might want to use only some of them, then instead of:
request()->all()
you can use:
request()->only('sort_by', 'sort_order', 'filter_by', 'year')
I want to do a webshop, where users pay via paypal. Everything works perfectly, if I use the default currencies. However I want to pay with Hungarian Forint, which is not working.
In the merchant library I have found this:
public static $NUMERIC_CURRENCY_CODES = array(
'AUD' => '036',
'CAD' => '124',
'EUR' => '978',
'GBP' => '826',
'NZD' => '554',
'USD' => '840',
);
So I added a new line: 'HUF' => '348', but regardless when I want to pass the HUF parameter to the CI-Merchant, its not working. Matter of fact, I can change anything in this array, the results will be the same
This is how I pass the parameters:
$params = array(
'amount' => $osszeg,
'currency' => 'HUF',
'return_url' => 'something',
'cancel_url' => 'something');
(paypal supports Hungarian forint, so the problem is not there)
Is there any way to make this work? Thank you very much for your answers in advance.
Firstly, don't use CI Merchant, it has been unsupported for nearly a year now. Omnipay is its replacement.
If you must use CI Merchant, then the currency parameter is correct. You don't need to add the numeric currency code, since paypal uses standard 3 letter currency codes. It's passed through to paypal here:
https://github.com/expressodev/ci-merchant/blob/master/libraries/merchant/merchant_paypal_base.php#L94
Now since you only say it's 'not working', I don't know what the actual problem is so can't really help diagnose. If there is an error message, what is it? I suspect that the currency is not enabled on your paypal account.
Trying to implement Factual API with provided Ruby wrapper. Looking to return all Bars within certain number of meters of a geo point. My query looks like this:
factual.table("places").search("category_id"=>"312").geo("$circle" => {"$center" => [40.7811, -73.98], "$meters" => 10000}).rows
This returns a 200:OK response, but 0 records (even though that location is in Manhattan). I'm pretty sure there's a problem with the way I'm passing in the category info.
Per the API documentation, I've also tried passing the category data like this, which returns a syntax error:
factual.table("places").filters("category_ids" => {"category_ids":["6"]}).geo("$circle" => {"$center" => [40.7811, -73.98], "$meters" => 10000}).rows
and this, which returns the Factual error *references unknown field category_ids*:
factual.table("places").filters("category_ids" => {"$in" => ["312", "338"]}).geo("$circle" => {"$center" => [40.7811, -73.98], "$meters" => 10000}).rows
I'm following the documentation samples here and using v3: https://github.com/Factual/factual-ruby-driver/wiki/Read-API and here: http://developer.factual.com/display/docs/Places+API+-+Global+Place+Attributes
EDIT:
I've also tried changing the filters method to search like this:
factual.table("places").search("category_ids" => {"$in" => ["312", "338"]}).geo("$circle" => {"$center" => [40.7811, -73.98], "$meters" => 10000}).rows
This returns records with 338 in the address, irrespective of category. Very strange. I've been trying different things for hours. I'm pretty sure it's an issue with how I'm passing in category information. I'm following the docs as closely as I can, but I can't get it to work.
Try this
factual.table("places").filters("category" => "Bars")
.geo("$circle" => {"$center" =>[40.7811, -73.98] , "$meters" => 1000}).rows
The following two criteria sets give me identical results using Lithium and MongoDB. Both are equally easy to read and write. Should I prefer one over the other for efficiency reasons, or is one just Lithium/MongoDB syntactic sugar for the other?
$criteria = array(
'fields' => array('_id', 'title', 'created', 'edited', 'username'),
'order' => {'edited' => 'ASC'},
'limit' => 3
);
And
$criteria = array(
'$orderby' => array('edited' => 'ASC'),
'fields' => array('_id', 'title', 'created', 'edited', 'username'),
'limit' => 3
);
Follow up question: I really struggled to figure out the right syntax to use for order and $orderby, and in general I find Lithium's code pretty hard to grok. Do you have any suggestions on how best to approach the codebase for better/faster understanding?
PS: I realise the follow up question might not really be StackOverflow style - but there are other posts on SO and elsewhere which hint at exactly this problem (e.g. Lithium apps that go beyond CRUD). Any input on this could be really valuable!
Lithium translate 'order' to a MongoBD sort() source
MongoDB's $orderby directive is equivalent to calling sort() after a find() source
So both are equivalent.
I'll go with order since it's a consistent and unified API to interact with any underlying datasource.
Hope it helps