How do I add all the prices on the mongodb and put all the sum of all prices on the front end using react I'm using mern - mern

this is the mongodb and I want to add ll the prices and show all the sum fo prices to front end what should I do to add all this

Related

add new column to existing table and show it into a view blade (LARAVEL,mysql)

my goal is to display the total of the SUCCESS payments in my project in home blade.
if is it possible to do this without creating new column its ok.
step 1 :
i have a table named (payments) , i want to add a new column named (total_amount) ,
i already have the amount column so i need to put the SUM of this column to the new one (total_amount).
NOTE : i need just the success payments , so the SUM query need a condition where status = 'success'
enter image description here
step 2 :
after getting the total amount , i want to show it into home view blade .
i just want to show the total of payments in < h1 >
please i need step by step and what i should put in the controller and model... ,
i try to get the total without creating a new column but wasn't work so i think that i need to create his column first and get the value of this column, note that its just a one value not array.
You don't need to have a sum column. In general, you should avoid storing aggregates. Do something like this instead:
[Controller]
$sum = Payment::where('status', 'success')->sum('amount');
Then when you construct the view, make sure to compact sum with the other variables:
[Controller]
return view('yourtemplate', compact( 'all', 'your', 'other', 'vars', 'sum' ));
Then in the view itself, just echo out the sum wherever you want it:
[View] <h1>{{ $sum }}</h1>
EDIT: Thought of another way. If you already have the payments as a collection in that view, you can just use the collection helper:
[View] <h1>{{ $payments->where('status', 'success')->sum('amount') }}</h1>
If I understand your question, and you need the total amount of every successfully payment? If the question is yes, here is your query (assuming you have created your Payment model).
Payment::selectRaw('SUM("amount")->where('status', 'success')->first();

laravel search results grouping

I have a car rental website built with Laravel and when I search for a car I want the results to be grouped by brand for example (mercedes, ford, bmw). and when I click on "mercedes" for example then it has to display just " mercedes" cars in another page.
In other word I don't want to display all cars in one page. In first page I want grouped results. And when I click on "mercdes" then a new get request will be sent to get only "mercedes" cars in separate page.
I used groupBy() collection helper to group the results and display it in the first page. But the problem is the second step. I thought about using the same database query as the first except adding constraint for example (where brand = mercedes) to get only mercedes cars.
How can I achieve it ?
Laravel has a special formula for that is query builder . You can easily make your query by using this query builder. you can make a query by using the following query
$users = DB::table('cars')
->groupBy('brand')
->get();
you can see the full documentation of query builder Laravel Query Builder Documentation

MS-Access - DLookup using values entered on form

I am a complete novice with no experience of building a database. I have been following a few online tutorials to help with a little project I want to work on.
Here is a pic of my current table relationships:
I have a form where I want to enter invoice details. I want to be able to select a product from a drop-down and for it to automatically populate a text box with the cost. The problem i have is, depending on the customer, the cost can be different.
Here is a pic of my form:
I have tried using DLookUp in the Unit Price field but i just can't seem to get the hang of it.
Basically, in pseudo code, i want the unit price field to:
Select From tblPrices Where PriceID =
I've tried:
=DLookUp([Product],"tblPrices","PriceID = " & [Forms]![tblInvoice]![SalesTypeID])
but it is returning the ID of the selected from product in the form from the Products table ?!

Product Quantity in configure product page whmcs

Is there any way to add a field to enter the quantity of the product in configureproduct.tpl file ? Like the one in Cart page ? And I need the same using ajax. The Quantity provided in this new field should be updated in the cart page also.
Thanks
Check Configurable Option in WHMCS, there is quantity field.
Open Configurable Options, from Setup > Products/Services.
Add group for the product (Group of fields).
Assign products to have this group of Configurable Options.
Add Configurable Option and select type as Quantity.

Access Report - Show Week Ending Date

I have an Access 2000 report based on a query like this
SELECT
...
FROM Clients AS wc INNER JOIN ...
WHERE ((wo.OfferStatusID)=3) AND
((DatePart("ww",[wo.StatusTimeStamp]))=DatePart("ww",[Enter Week End Date]))
AND ((Year([wo.StatusTimeStamp]))=Year(Date())));
The where clause allows you to enter the 'Week End Date' and it finds all of the records for the Sunday-Saturday week that contains the end date.
My problem is I need to include the Saturday end date on the report so that the header reads '... for week ending 5/9/09' and I can't figure out how to get that date without the query asking me for it a second time.
Is there a way to force Access to return the parameter entered as another field in the results, or another way to get that week ending date?
Continuing to poke around in the query designer I discovered that I could add this to the SELECT clause and get the value entered added to each row:
[Enter Week End Date] AS WeekEndDate
This works, but I am still open to other suggestions.
You could stack two queries (make one the source of the other). This would be pretty MS Access'y. However, if you have it working now, I'd stick with what you have. It's probably cleaner.
Another approach is to use a form to grab the query params first, and reference the form control in the query. For instance, with your example, create a form called frmGetDateParam, and add a textbox called txtDate. Change the format to a date, perhaps add some validation, doesn't matter. Add a command button to the form which opens up the report. Then, change your query to look like this :-
SELECT
...
FROM Clients AS wc INNER JOIN ...
WHERE ((wo.OfferStatusID)=3) AND
((DatePart("ww",[wo.StatusTimeStamp]))=DatePart("ww",Forms!frmGetDateParam!txtDate))
AND ((Year([Forms!frmGetDateParam!txtDate]))=Year(Date())));
You can also reference Forms!frmGetDateParam!txtDate as a field on your report.
The only downside to this approach is that if you try to open the query/report without the parameter form being open, then the query will still prompt you for the date value.