Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Improve this question
In my DTO i have invoice list and receipt list. I need to bind the invoices in the drop down list. For this i have the following conditions
I need to bind all the invoices with the total amount of that invoice receipts is less than the invoice value
My Invoice entity have ID, Number, Amount
My Receipt entry have ID, InvoiceID, Amount
I need to group the receipt list with invoice id and sum of the receipt amount must be less than Amount of that invoice list. How can i use linq or lamda doe this
Not sure exactly what you need as the output but the join should look something like this...
Invoices
.GroupJoin(Receipts,
r => r.ID,
i => i.InvoiceID,
(i, ir) => new {
i.ID,
i.Number,
Amount= i.Amount,
RAmount = ir.Sum(r => r.Amount)})
.Where(i => i.RAmount < i.Amount)
.Select(i => new {i.Number,i.ID}) //Project however you want to get your list item
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed last month.
Improve this question
I need all reports with all officers included in the participants column.
please check the attached image.
https://prnt.sc/CRoELD48J-L5
You should really have a participant pivot table with report_id and officer_id, and create proper relationships.
What you're asking for is possible through loops and lazy loading, but it will be extremely slow and unoptimized.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Each user can follow many categories (many to many),
Each category has many posts (one to many),
I want to get all posts followed by the user and sort them by date.
Is there any way to do that with Eloquent?
There may be a different way, but how I'd probably do it is with two queries:
// Get the IDs of the categories
$categoryIds = $user->categories()->pluck('id');
// Pull the posts with those category IDs
$posts = Post::whereIn('category_id', $categoryIds)->get();
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
When I have to store informations about city, state and country of users in a table, which one below is the best way?
Have 'state', 'city' and 'country' fields in the users table
Have 'id_city' in the users table and:
a table 'cities' with 'id', 'name' and 'id_state'
a table 'states' with 'id', 'name' and 'id_country'
a table 'countries' with 'id' and 'name'
The second one will avoid to have a wrong city in a wrong state and in a wrong country, as:
'Munique', 'NY' - 'Brazil'.
But when I need to select the country of an user I'll need 3 JOINS!
So, what's the best way to do it?
Stick to option 2.
Actually, based on the use case and your application user amount. This would not be a issue. If it was, cache would help (These data is kind of static data. It is unusual for them to change).
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I need a list of the stock levels of all products, per store, for a specific date in the past. Is there a way to go back and see how many items were in stock for product X, and then for all products?
unfortunately, no. There is no history of the stock, or any "snapshots" of the product stock at any time.
What you can do, but this is not 100% reliable since the stock can be altered manually, is to get the current stock and subtract from it the quantity ordered since the day you want until now. To get the qty ordered for a product you can use one of the methods described here. All of them use the sales reports models to retrieve data.
Or you can try this one, but you need to add the date filters by yourself.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I am using Magento to build a bookshop
A book includes:
has many attributes such as: name, prices, weight, etc...
belong to one publisher
belong to one-or-many categories
has many distributors which includes many attributes:
name
address
phone/email
So, when I create a book in Admin Management Panel, how I could:
Make a list of distributors.
Add a book (product) refer to
one-or-many distributors?
Make a multiselect attribute called distributors. This will give you the possibility of adding one or multiple distributors to products. However, the attribute options only have IDs, label fields, and nothing else.
To extend this, you will need to write you own module with a database table containing your fields and a reference to the attribute option:
Distributor ID (reference to option_id in eav_attribute_option)
Name
Address
Phone
Email
You will probably also need to write a backend interface for editing this data, and some functions to access distributor data by attribute option ID etc.