Hi Alex, How do I download all the episodes at once?
Hello Alex, can subscribers have access to the latest source code please? Even if it's got bugs in it.
Another way of calculating the Order status I would like to share here:
On the Order.php model, I define this array:
1public $statuses = [2 'placed_at' => 'Order Placed',3 'packaged_at' => 'Order Packaged',4 'shipped_at' => 'Order Shipped',5];
Then, the status() function looks as follows:
1public function status()2{3 return collect($this->statuses)4 ->last(fn ($status, $key) => filled($this->{$key}));5}
If anyone has a problem with this error
Undefined variable $meilisearchClientClassName
It is not the course
Laravel Scout just updated as of yesterday 06.01.2023 to 0.7.1
The package ahs a bug in it
This version works 0.7.0
Hope it helps
Hi guys
Does anyone know how to change the limits on Meilisearch to bring more results down than the default of 20 please.
Further to my posts final conclusion on Meilisearch
Not the best search engine in the world
Using the same techiques as in the video Alex only shows two products
Doing the same thing brings the variations up on the category where no products are actually in that category so when you click to choose that product you get an error
CALL TO MAP FUNCTION A STRING
Thats problem one problem two is that if you have 9 products in that category the Meislearch will only show 6 on v0.21.1
On later versions it only shows 5 products so if you want to show the customer 100 products in that category Meilisearch is useless
public $category; public function render() { $search = Product::search('', function ($meilisearch, string $query, array $options) {
1 $options['facetsDistribution'] = ['colour', 'size']; 2 3 return $meilisearch->search($query, $options); 4 5 }) 6 ->raw(); 7 8 $products = $this->category->products->find(collect($search['hits'])->pluck('id')); 910 return view('livewire.product-browser',[11 'products' => $products12 ]);13}
As you can see exactly the same code as Alex types it bring back 6 and thats it.
[Lecture 19] What is if we delete a user? this will fail because of the user_id in the Cart. I have fixed that with a deleting method in User model. Then also the Email verification will fail according to breeze provided tests, wich i fixed with set uuid in cart to nullable.
Not sure that are the best way for fixing that but it works with all tests green.
I did this
public function closeyouraccount(User $user) { DB::table('orders') ->where('user_id', $user->id) ->update(['user_id' => null]);
1User::where('accountnumber', $user->accountnumber)2 ->delete();3Auth::logout();
And all other other tables
1 return redirect('/login')->with('status', 'Thankyou for being part of The Official Site Of Lee Weaver. You account was closed and data destroyed. Sorry to see you go.');2}
OK that seems to be better, thanks
Hi guys question and I know this is nothing to do with what Alex has showed
Why is Meissearch only showing 6 products in the category when there are 18 and why are the filters that are not in that catgory showing any answers
Update to my previous posts
For Meilsearch to work you would need Version 0.21.1
And this in your json
"meilisearch/meilisearch-php": "^0.19.0"
What Alex is showing is working on mine with these [versions but not repeat not work with newer versions
Facets Distribution was changed as of version 27 to facets which after trying too work with it with this course was a waste of time
So to conclude
When installing Meilisearch from their official website where you see
git checkout latest
Change latest to v0.21.1
Use the link for meilisearch.php in the composer json and what Alex is showing will work .
A note for Meiliseatrch developers is stop changing things and make the documentation easier to understand
It took me 3 days to work this out .
Hope it helps
A lot of people are probably wondering why facets distribution is causing so many problems
In the video Alex explains that the filters must be added manually in Postman
There is another way by creating a Scout Service Provider and under register
$client = app(Client::class); $client->index('products') ->updateFilterableAttributes(['colour', 'fragrance', 'theme', 'price', 'category_ids', 'size']);
This is mine
Now this sort of works but when I click on the category the attributes for every product in the database comes up not just the category
Now why is this
If you notice Alex is using Meilisearch v0.25.0
In this version at the time of recording everything was upto date
However Meilisearch has upgraded by 5 versions since then
In the the video on the product browser Alex shows this
$options['facetsDistribution'] = ['colour', 'fragrance', 'theme', 'size'];
On version 30 of Meilsearch facetsDistribution is un recognised because Meilisearch has took this out
And with no easy to understand documentation form Meilsearch were gonna struggle
One person tried Facets and it worked I tried it and it doesnt work .
Thats why thers so many problems .
Attributes and so on is defined in scout.php config file. https://laravel.com/docs/9.x/scout#configuring-filterable-data-for-meilisearch hope it will help. I am on the latest without any problems so far.
Doing exactly waht you said
$search = Product::search('', function ($meilisearch, string $query, array $options) {
1$filters = collect($this->queryFilters)->filter(fn($filter) => !empty($filter)) 2 ->recursive() 3 ->map(function ($value, $key) { 4 return $value->map(fn ($value) => $key . ' = "' . $value . '"'); 5}) 6->flatten() 7->join(' OR '); 8 9$options['filter'] = null;1011if($filters)12{13$options['filter'] = $filters;14}1516if($this->priceRange['max'])17{18$options['facets'] = ['colour','fragrance', 'size', 'price', 'theme'];1920 $options['filter'] .= (isset($options['filter']) ? ' AND ' : '') . 'price < ' . $this->priceRange['max'];21}22232425return $meilisearch->search($query, $options);2627})28->raw();2930$products = $this->category->products->find(collect($search['hits'])->pluck('id'));313233$maxPrice = $this->category->products->max('price');3435$this->priceRange['max'] = $this->priceRange['max'] ?: $maxPrice;363738return view('livewire.product-browser', [39 'currencies' => $currencies,40 'products' => $products,41 'filters' => $search['facets'],42 'maxPrice' => $maxPrice43]);
Scout.php
'meilisearch' => [ 'host' => env('MEILISEARCH_HOST', 'http://localhost:7700'), 'key' => env('MEILISEARCH_KEY', null), 'settings' => [ \App\Models\Product::class => [ 'updateFilterableAttributes'=> ['colour','fragrance', 'theme', 'size', 'category_ids', 'price',], 'updateStopWords' => ['the','a','an'], ], ],
Error
Undefined array key "facets"
Latest version happens everytime so I dont know how you got it working ha ha
"filterableAttributes" not "updateFilterableAttributes" adn also index-settings instead of settings
https://laravel.com/docs/9.x/scout#configuring-filterable-data-for-meilisearch have you see this?
filterableAttributes
Done it
Undefined array key "facets"
Still the same so you must have installed somethig that works
in config/scout is already an example to fill out.
Ive read that webpage and followed the instructions
php artisan scout:sync-index-settings
No index settings found for the "meilisearch" engine.
Thats the error
index-settings instead oh just settings?
hmm... seems i can't help you, so sorry, i have tried.
Right Ive read it updated it found the product index and gone through that with a fine tooth comb
Flushed the products reimported the products rest and updated them, in post man
It found the index
Still the same error
Undefined array key "facets"
Also I have 9 products in the category and with all that done it still shows 6
You musty have done something to get it working
Ive got it working
'filters' => $search['facetDistribution'], not "'filters' => $search['facets']," right? i have just seen it.
No thats got nothing to with it
This line
1$options['filter'] = 'category_ids = ' . $this->category->id;
Alex refactors it to this
1$products = $this->category->products->find(collect($search['hits'])->pluck('id'));
And deletes the first line
Wrong
As soon as I left
1$options['filter'] = 'category_ids = ' . $this->category->id;
That line in worked liked a charm
$search = Product::search('', function ($meilisearch, string $query, array $options) {
1 $filters = collect($this->queryFilters)->filter(fn($filter) => !empty($filter)) 2 ->recursive() 3 ->map(function ($value, $key) { 4 5 return $value->map(fn ($value) => $key . ' = "' . $value . '"'); 6 7 }) 8 ->flatten() 9 ->join(' OR ');10 $options['filter'] = null;1112 $options['filter'] = 'category_ids = ' . $this->category->id;1314 $options['facetsDistribution'] = ['colour', 'size', 'fragrance', 'theme'];151617 if($filters)18 {1920 $options['filter'] = $filters;2122 }2324 if($this->priceRange['max'])25 {26 $options['filter'] .= (isset($options['filter']) ? ' AND ' : '') . 'price < ' . $this->priceRange['max'];27 }2829 return $meilisearch->search($query, $options);3031})->raw();323334$maxPrice = $this->category->products->max('price');353637$products = $this->category->products->find(collect($search['hits'])->pluck('id'));
Hi. Help my ))) Lesson #33
Attribute category_ids
is not filterable. This index does not have configured filterable attributes. 1:13 category_ids = 2 (View: C:\xampp\htdocs\app-shop\resources\views\categories\show.blade.php)
You need to make this field filterable!
First of all, add it to the "toSerachableArray()" function as follows:
public function toSearchableArray(): array { return array_merge( [ // ...
1 'category_ids' => $this->categories->pluck('id'),23 ],4 // ...5 );6}
Then it would help if you let Meilisearch know that this field is searchable. You can use the Postman Meiliearch collection, as Alex shows in the video. Another way of doing it, which is the way I did is by creating a new command that will add any field to Meilisearch.
Good luck,
Thank you very much!
Hi community, I am struggling with the price filter.
1 2$maxPrice = $category->products->max(fn ($product) => $product->price->getAmount()); 3$price = $request->get('price') ?? $maxPrice; 4 5 $search = Product::search( 6 query: trim($request->get('search')) ?? '', 7 callback: function (Indexes $meilisearch, string $query, array $options) use ($category, $filters, $price) { 8 $options['filter'] = 'category_ids = ' . $category->id; 910 if ($filters)11 {12 $options['filter'] .= ' AND ' . $filters;13 }1415 $options['filter'] .= ' AND price <= ' . $price;1617 $options['facets'] = ['size', 'color'];1819 return $meilisearch->search($query, $options);20 },21 )
The price filter here is not working. I've been reading about an issue with Laravel Scout/Meilisearch that integers are considered strings; hence, the '<=' never works. None of the products is returned.
I even tried to add a where() clause on the Product::search() before calling get(). This returns all products ignoring the price filter.
->where('price <=', $price)
I appreciate your feedback.
Thanks Bilal
My bad,
Inside the toSearchableArray() function, since I am using Price as Money:
public function toSearchableArray(): array { return array_merge( [ 'id' => $this->id, 'title' => $this->title, 'slug' => $this->slug, 'description' => $this->description, 'price' => intVal($this->price->getAmount()), 'category_ids' => $this->categories->pluck('id'), ], $this->variations->groupBy('type') ->mapWithKeys(fn ($variations, $key) => [ $key => $variations->pluck('title')]) ->toArray(), ); }
$this->price->getAmount() returns a string. Now I cast to integer; everything works well.
In case someone faces the same issue in the future :-)
Facets distribution problem solved
Version 25 is still available
OPEN YOUR TERMINAL
git clone https://github.com/meilisearch/meilisearch cd meilisearch
On documentation this will install the latest version which is 30
git checkout latest
DO NOT INSTALL THIS
INSTALLL THIS VERSION
git checkout V0.25
rustup update
cargo build --release
./target/release/meilisearch
To run this in production on ubuntu
https://lindevs.com/install-meilisearch-on-ubuntu
THE LINK FOR UBUNTU
sudo wget -qO /usr/local/bin/meilisearch https://github.com/meilisearch/meilisearch/releases/v0.25.0/download/meilisearch-linux-amd64
Please note installing Version 30 until alec updates the course to show us about the facet distribution will not work on version 30
You will also need to update your Compser.json file for the meilisearch.php to version 23
https://github.com/meilisearch/meilisearch-php/releases/tag/v0.23.0
Hope that heps everyone
Any ideas guys
Json deserialize error: unknown field facetsDistribution
, expected one of q
, offset
, limit
, page
, hitsPerPage
, attributesToRetrieve
, attributesToCrop
, cropLength
, attributesToHighlight
, showMatchesPosition
, filter
, sort
, facets
, highlightPreTag
, highlightPostTag
, cropMarker
, matchingStrategy
at line 1 column 28
Using Meilisearch v0.30.0
Version v.0.25.0 used in the video is not longer available
Hi Alex,
I would like to ask, why the payment intent is attached to the cart and after successful payment that the cart is deleted and the order is created. This way we know that the order is paid because we create it after successful payment, but we have lost the payment intent relation. Maybe we can preserve converted carts and link it the with corresponding order or we can create order payments table, where we can add all order payments.
Hope you are well and continue this course as it is in Development for quite a long time.
Hi Alex,
Could you please provide a better way of getting cart variation stocks amount different from $variation->stocks->sum('amount') as stocks relation will grow with orders and refills
Also why would you prefer Laravel collection methods instead of normal foreach in syncAvailableQuantities for building $syncedQuantities as this calls a lot of methods and callbacks instead of 1 native loop?
Thank you for time and outstanding work!
Hi, on constrained columns index is added automatically, but parent_id does not have a foreign key or index on products and variations tables, is that intentional?
Hello, no download project files link ?
hi, what is the database client software used ?
Sequel Pro
TablePlus
Hi folks. I struggled with this error "Json deserialize error: unknown field facetsDistribution
, expected one of q
, offset
, ...". Unknown to me, there had been a breaking change for the search endpoint. "facetsDistribution" search parameter has now been renamed "facets". https://github.com/meilisearch/MeiliSearch/releases. Thought that may help someone save some hours. I found it the hard way.
Thanks mate.
Undefined array key "facets"
Thats what get using facets
$search = Product::search('', function ($meilisearch, string $query, array $options) {
1 $options['facets'] = ['colour', 'fragrance']; 2 return $meilisearch->search($query, $options); 3 4}) 5->raw(); 6 7 8$products = $this->category->products->find(collect($search['hits'])->pluck('id')); 9101112return view('livewire.product-browser', [13 'currencies' => $currencies,14 'products' => $products,15 'filters' => $search['facets']16]);
I dont understand stucked again video 36. Import to postman from where?
Import from here: https://docs.meilisearch.com/learn/cookbooks/postman_collection.html#import-the-collection
Hi Alex. Excellent course. But I found a small flaw in EP39. The max price filter does not accept a different subvariant price (different price per color/size variant). Can you fix it? Thank you!
The link of the image is for me: http://localhost/storage/2/nike.jpeg But the image does not appear in browser if I enter this link, how does it work? Thanks
Did you remember to link the storage folder? php artisan storage:link
hello please can anyone help i get a mysql error use the laravel adjacency helper tree()->get()->toTree() i've search for a solution online but nothing
Add HasRecursiveRelationships to Category Model...
Where can I find all the coding? I am jumping between sections to learn what I need.
any suggestions on how to build up $queryFilters in situations where your "variations" are in sepperate tables (color in one table, size in another)?
What is the key shortcut for VS Code for adding the namespace on top of the classes?
Use the PHP Namespace Resolver extension and then click the class name and press Ctrl + Alt + I (i) on Windows
When we created the image gallery it was mentioned that we could present the images of the variations. How can I do this? I tried in many ways and I couldn't.
I tried: $this->product->variations->getMedia();
But it always gives an error that the collection does not exist or the method does not exist. How can I get the images of the variations? Because I'm interested in having an image of the product and the variations
Hi All. Alex please he could show us you how to do pagination on products because when there are a lot of products it can be a lot with ram memory. THX PS: It is about filtering products and displaying in categories.
Is this course now finished? I have enjoyed the content so far but if this is the end I am bitterly disappointed, I don't know if it's just me but I expected a lot more and think this is nowhere near complete yes it matches the demo on the first video but I just assumed that was a teaser and there was more behind the scenes, are we expected to always enter data directly into the database and manually upload product images via the command line, I expected that these things would at least be included in some sort of admin panel. There is also a lot of messy code were Alex says we'll come back to that later... we'll fix it we'll just do it like that for now... then never returns to it again? It still says under development but I have been following for over a week now with no new content.
ive tweaked a few things and deployed the app
https://online-shoe-store.herokuapp.com/
this course is a very good reference for making a portfolio project and i hope Alex will continue updating this course
Hi Chris! Because admin panels are essentially a course in themselves, I never intended to include one here. Understand that it’s pretty annoying having to do this via the database and command line but Nova would work great for this if you have it.
With the bits to fix up and refactor, I completely agree and I have a big list based on feedback which I’ll be adding. If you need anything specific feel free to get in touch and I’d be happy to help!
Appreciate your comments :)
I told you it was not finished alex didnt I also Alex you eith need to do a course on translations with laravel loclaistion now t here are some good ones on youtube for the route thats easy but wen it comes to this translation on the models not one perosn on you tube can do it and github have manamras package but understanding it you need to be einstien so som thats soehing for you too look at bindin maodels into trnslations a for an admin anel for the gentle man Nova costs money Laravel Voyager does not and if Alex does not wnat to do a tutroial on voayager thers plenty on you tube easy ones aslo Alex the single product needs doing and if you can shipping syesp ie royal wail with weights eect because in the modern retaill market onlie shops must dispaly the wieehgt sihpping sit and the rpice
How are you? Why files attached with videos when I toggle removed from the site
please reply
why files attached with videos are hidden from videos?
Great course! I have just noticed that the subtotal is getting sent through to the orders page which does not include shipping. Should I change the subtotal column in the orders table to total or add an extra column and include both? Then to get the total should I use getTotalProperty() or create a total() method in either App\Cart\Cart.php or App\Models\Order.php?
Sorted it it was me trying to cut conrers thinking I didnt need to to something I did I didnt fill i something maughty
Anyone come across this
Illuminate\Database\Eloquent\Builder::firstOrCreate(): Argument #1 ($attributes) must be of type array, App\Models\ShippingAddress given, called in /var/www/vhosts/leeweaver.uk/app/Http/Livewire/Checkout.php on line 112
Alex, do you have the completed code on Github or anything please...I need to look at something and why me version isn't working.
Alex how are you putting them categories in a dropdown menu
Really nice course so far(@part 30). I am enjoying it, just wondering if this application architecture can cover simple products also(for example a product as it is without any variations at all) along with the variable products without poorly "patching" it (for example fake variations). Maybe I am wrong but as it stands I think it will need a good revamp to be able to handle simple type products. I d love to hear your thoughts about it guys.
I tried it on the variations with the Sku variant on the products model and it doesnt work keeps saying foreach must be type of array string given when trying bring the product down so its looking for an array of products which would not be an array on the products table I keep asking Alex to show ius everyone is hes not answering
We could try to use a fake variation for the simple products and exclude it from filters, etc. but that is exactly what i am trying to avoid. I guess the whole product logic(components, models and cart) need a revamp to be able to use simple products without variations.
I tried it wont work because the the variations not only works with an array it also needs a parent_id for the adjency list and that whould have to be in the products table which again takes in back to to a dropdown so you would need a new model and redirect if the product is sign le product with a a count
I think i figured it if it works
Anyone come across this error
Illuminate\Database\Eloquent\Builder::firstOrCreate(): Argument #1 ($attributes) must be of type array, App\Models\ShippingAddress given, called in C:\wamp64\www\leeweaver\app\Http\Livewire\Checkout.php on line 118
($this->shippingAddress = $this->shippingAddress->firstOrCreate($this->shippingForm)) ?->user() ->associate(auth()->user()) ->save();
Alex A little information for you
Stripe is very strict on what they allow to to be sold.
I sell spiritual products and when to Stripe and had it working a customer paid for a spiritual product and we had o give the money back and the customer was furious because Stripe said they dont allow any Spiritual services entertainment services like netflix because there to high risk Working through Pay Pal have never had problems at all
Also Im working on Ubuntu 20:14 and after uploading the files we have the same problem
Invalid facet distribution, the fields box, size
are not set as filterable.
Now doing this on local host it works hw do we get this working update the facets in product whats the script please and can you please do a video on hooking pay pal up to this Im using a the moment Ominpay with Paypal sdk
Hi, I have this error: Invalid facet distribution, the fields color, size
are not set as filterable.
yet I followed the tutorial to the letter.
I don't understand where the error comes from
you need to add the attributes to the list of attributes that can be used for filtering on meilisearch
the easiest solutions to do this
1$client = app(Client::class);2$client->index('products')3->updateFilterableAttributes(['color', 'size'])
once before the search to update the index on meilisearch
Thanks, that's exactly what I did! , I created a ScoutServiceProvider, and I put the code you indicated
Matey it worked in production thankyou Alex you should have should us that lol make sure import the meilisearch client tho and add the service provider to config/app
Hi I can't find tree method in staudenmeir/laravel-adjacency-list package. It seems missing
maybe because you didn't search? https://github.com/staudenmeir/laravel-adjacency-list#trees
Does anyone know why I keep getting
Attribute `price` is not filterable. Available filterable attributes are: ``. 1:6 price = 45500
when a closure is passed with a filter option.
Product's toSearchable
1public function toSearchableArray(): array 2 { 3 return [ 4 'id' => $this->id, 5 'title' => $this->title, 6 'slug' => $this->slug, 7 'price' => $this->price, 8 'description' => $this->description, 9 'category_ids' => $this->load('categories')->categories->pluck('id')->toArray(),10 'image' => $this->getFirstMediaUrl(),11 ];12 }
The related search
1Product::search('', function (Indexes $meilisearch, string $query, array $options) {2 $options['filter'] = 'price = 45500';3 return $meilisearch->search($query,$options);4})->get();
Thanks.
You have to use Postman and import the meilisearch into postman and goto to update the filterable attributes Alex shows you from Episode 31 onwards but from your doing $options['filter'] = 'price = 45500'; no its just 'price' but the problem is if your like me ad postman wont update the filterable attributes you got a problem Alex some where in the videos shows how to do it without post man but Ive not seen that yet hope that helps
https://docs.meilisearch.com/learn/cookbooks/postman_collection.html#edit-the-configuration thats the link
The list of attributes that can be used for filtering in Meilisearch is null by default, to get around it,
add all your settings inside config/scout.php
1'meilisearch' => [ 2 'host' => env('MEILISEARCH_HOST', 'http://localhost:7700'), 3 'key' => env('MEILISEARCH_KEY', null), 4 'settings' => [ 5 \App\Models\Product::class => [ 6 'updateFilterableAttributes'=> ['director','genres',], 7 'updateStopWords' => ['the','a','an'], 8 9 ],10 ],11],
and in the register method of the AppServiceProvider
sync the settings with meilisearch. You can put it in separate service provider if you want
1public function register() 2 { 3 if (class_exists(MeiliSearch::class)) { 4 $client = app(Client::class); 5 $config = config('scout.meilisearch.settings'); 6 collect($config) 7 ->each(function ($settings, $class) use ($client) { 8 $model = new $class; 9 $index = $client->index($model->searchableAs());10 collect($settings)11 ->each(function ($params, $method) use ($index) {12 $index->{$method}($params);13 });1415 });16 }1718 }
you can also put into an artisan command
Hey Selorm, adding that service provider do you need to use postman in order to make the update in meilishearch?
N you dont as long you add the values in the e service provider it will work just make sure your flush and import to "app\Models\Product" to update
Lee, thank you so much mate!!
Selorm, thanks in Petabytes for your most valuable solution. You have ended 2 days of frustrating search for solution to the 'unfilterable' error. I appreciate.
Right Meilisearch is picking up the variation indexes
public function toSearchableArray() { return array_merge([
1 'id' => $this->id, 2 'title' => $this->title, 3 'slug' => $this->slug, 4 'price' => $this->price, 5 'category_ids' => $this->categories->pluck('id')->toArray(), 6 ], 7 8 $this->variations->groupBy('type') 910 ->mapWithKeys(fn ($variation, $key) => [1112 $key = $variation->pluck('title')13 ])1415 ->toArray()16);
Dispaying variation not the title
0
array ID 3 TITLE 10 ml Lavender Oil SLUG 10ml-lavender-essential-oil PRICE 3.49 CATEGORY_IDS
array
Trying update in post man { "filterableAttributes": ["size", "category_ids"] }
This is all i get
{ "uid": 61, "indexUid": "products", "status": "enqueued", "type": "settingsUpdate", "enqueuedAt": "2022-03-31T18:57:16.6859462Z" }
Any suggesitions
Hi Alex, This package staudenmeir/laravel-adjacency-list doesn't seem to work anymore. I got tree notice "method tree() not found".
You need to add
1use HasRecursiveRelationships;
to your model. ie Category
or Variation
Hi Selorn I added it but it didn't work. You can check it on this link https://github.com/tuanphamxtasea/E-commerce/issues/1 Code in master branch
Hi Selorm, Do you have git repository ? I think I missing something. I want to compare with your code. Thanks
Fixed. I need to set parent_id to null in database
After looking at this problem Undefined array key "facetsDistribution" it seems that you habe to change the the facet attributes in post man and update them after do that ad following Alex still Undefined array key "facetsDistribution"
I got tree notice "method tree() not found". Why is that ?
you need to add "use HasRecursiveRelationships;" to your model "Category or Variation"
I have already added it. The result like it "[]". Still them same Khalil
make sure tree() at beginning at the root
like : Category::tree()->get()->toTree();
not like: Category::anythingelse()->tree()->get()->toTree();
if its already at the root and not working can you share your code on github or somewhere else to take a look at it
Here is the issue I meet, You can check it on this link https://github.com/tuanphamxtasea/E-commerce/issues/1 Code in master branch
Fixed. I need to set parent_id to null in database
A little information for you Centos 7 is not compatible with mealisearch only Centos 8 and if your using a Plesk Obsiddian thats not compatible wtth Centos 8 the only one for mealisearrch you can use is Ubuntu 20.04
Notifications was working on Alpine Js when adding the x-cloak and following he instuctions now not working
Updating item quantity it showing the quantity as one alex please help me on it
as an ecommerce app, this course should have image upload with file ponds. I understand we can do it, but rushing the course wont help us
Alex a quick one about the way Categories in EP 3 is setup using parent_id on the same table with slug being unique
How will a category structure of Brands
having Nike
as a child, same Nike
will be a child of Men, women, kids, and accessories category
, Adidas will have similar structure likewise all brands
1BRANDS2 NIKE ADIDAS3 MEN MEN4 WOMEN WOMEN5 KIDS KIDS6 ACCESSORIES ACCESSORIES
Clothing
will also have Men, Women, kids
as children, since slug is unique these items can't be duplicated. How will these issues be solved using the same structure demonstrated in Ep 3?
I think that maybe you can combine the slug from the parent category and the new category. Something like: nike-men
, adidas-men
Ep. 28 , when removing the second item in cart , cart component get refreshed but with wrong item due to lack of key
in Ep <livewire:cart-item :variation="$variation"/>
it should be <livewire:cart-item :variation="$variation" :key="$variation->id"/>
update: sorry i just noticed its fixed in EP 29
You helped me. Thanks.
http://laravel-ecommerce.test/storage/2/air-force-1-white.jpeg this URL is not showing image but URL is correct but while loading in another browser its not showing image
Hey Alex, can you please make a video about facetsDistribution? Right now we only have this:
1$options['facetsDistribution'] = ['size', 'color'];
But i think is important how to add this dynamically.
Hope this makes sense to you.
After looking at this problem Undefined array key "facetsDistribution" it seems that you habe to change the the facet attributes in post man and update them after do that ad following Alex still Undefined array key "facetsDistribution"
Now another question!! But now Livewire and image upload.
I'm applying what I'm learning in the course in a test e-commerce for the company I work for.
But I have the need that when the user chooses the product, he has to upload an image and I need to associate this image with the shopping cart and the order.
The upload itself, I'm already doing it and it falls into a temporary folder and saved in a temporary table to only later associate it with the user/cart/order.
But I can't find the best way to make this association. And I would like to use the media gallery as we use for product images.
Let's talk about Meilisearch!
It was very interesting and constructive to know how Meilisearch works to index products to speed up searches.
But let's suppose that we have an e-commerce administrative area and that we can add new products and variations, how can we make sure that meilisearch is always updated with the table of products and product variants that we have?
is it possible to do this directly from Laravel (PHP) or would we have to do a cronjob that every x time would update the meilisearch?
What would be the best way to get around this situation?
Have a look at their documentation. When you deploy the project there is the serve which will automatically run the commands everytime a record is added to the index.
Good to know, can you share the documentation link where you have this information?
https://docs.meilisearch.com/learn/cookbooks/running_production.html
Meilisearch wont work on centos 7 any suggestions
I using on Ubuntu 20.04 and owrks fine. Both in production (Digital Ocean) and on the development server (Office).
Ubuntu 20.04 works centos 7 does not work with meilisearch and if you have plesk obsidian centos 8 works with meilisearch but plesk is not upgrading to centos 8 so thats not oing to work you neeed to latest ubuntu
Undefined array key "facetsDistribution" Im trying to run meilisearch iin postman not a chance wont bring it up
Not too sure about that mate. You can create an issue in the official GitHub repository
Hi Alex the source code is bit confusing, are you preparing it like other series ?
can we also ask for realtime order updates and notifications on changes with orders within the website (not email), please. I know we can do $emit event but its not gonna do broadcasting. Doing that will fulfill the lack and take this project to next level!
I am waiting to hear back from you!
Use wire:poll
for that
This is not recommended as it makes too many Ajax requests. Conventional method is use to use event etc
I strongly recommend you introduce 3d secure payment with livewire without cashier using only stripe-php library. Most of the banks in europe these days only accepts 3d secure payments.
Alex, any reason you stopped putting the source with the courses?
Did you guys got an update on source codes ?
Following, I want to see the source code also
Suggestion: When saving the order details like subtotal, you should also be storing the "current" price of the variation that is ordered. Reason is when displaying back the orders, you're displaying the price for the variation as it currently is in the products table, but that price may have changed since the order was placed. If that happens the price show for the order won't match up to the prices of the variation.
Also, you should be storing the shipping rate that was applied to the order. Same scenario applies here as my paragraph above. I'm sure you're getting my point. Basically any price that was used during an order should be stored for future reference so that it is accurate to that actual order and not current pricing.
On episode 22 (Adding items to cart) I get a strange 500 error when using this code block to update the existing item quantity.
This this is the block in question:
1public function add(Variation $variation, $quantity = 1) 2{ 3 if ($existingVariation = $this->getVariation($variation)) { 4 $quantity += $existingVariation->pivot->quantity; 5 } 6 $this->instance()->variations()->syncWithoutDetaching([ 7 $variation->id => [ 8 'quantity' => min($quantity, $variation->stockCount()), 9 ],10 ]);11}
If I remove the IF Statement I can add 1 product, but if the IF Statement is there I get the livewire 500 error.
On the Network DevTools it say it's coming from the product-selector | Status 500 | Type: fetch
There is No Stacktrace or error. Only a blank black modal pops up.
Are you definitely using ->withPivot('quantity')
on the Cart variations relationship? Another thing to check would be the getVariation
method, if you could post it here.
Okay was definitely a Php error: found in the log Out of memory (allocated 23471325184) (tried to allocate 262144 bytes) Cart\Cart.php on line 65:
1protected function instance()2{3 if ($this->instance) {4 return $this->instance();5 }6 return $this->instance = \App\Models\Cart::whereUuid($this->session->get(config('cart.session.key')))->first();7}
Got caught in a infinite loop in the If statement. was returning the this->instance()
method rather only the $this->instance
.
This fixed all the problems. =)
1 protected function instance()2 {3 if ($this->instance) {4 return $this->instance;5 }6...
Hey Alex, the order confirmation template is missing from the download section.
Hi Angel, You can use the dashboard page as a template and make some changes.
Alex, I've noticed that when you type the curly braces you go back after adding one, to add the second. Isn't your vscode set up to just hit '{{' and then it completes the tags for you?
Hi, Alex WDYT? about use a view sum stocks and subtract the orders quantity, and after just make a join ?
Hi, anybody know how to implement 15% discount for first order if user registered?
Hi, I think that you need to check if is the first order for your user then, apply that discount.
Hey Alex, the checkout template is missing from download list.
Here is the code , in case you or someone else needs it.
1<a2 href="/cart"3 class="flex items-center text-sm font-medium text-gray-500 hover:text-gray-700 hover:border-gray-300 focus:outline-none focus:text-gray-700 focus:border-gray-300 transition duration-150 ease-in-out">4 Cart (0)5</a>
Thanks but no, I'm not talking about that piece of code.
Hi Alex, a checkout template would be very helpful
Sorry folks, it's just been added now 👍
nice, thanks!
Thanks
Ep. 48 - logged user save address perfectly, but if quest save address I get this error:
Call to undefined relationship [] on model [App\Models\ShippingAddress].
1($this->shippingAddress = ShippingAddress::whereBelongsTo(auth()->user())->firstOrCreate($this->shippingForm))23 ?->user()45 ->associate(auth()->user())67 ->save();
Anybody face to this issue?
This will be fixed over the next few episodes when we get to creating the order 👍
Alex your in trouble ive just seen that ive been thinking it was me naughty lol
what's the app you are using for Postgres? not seen that one before.
Postico
Hello, when creating a new category with new products and variations such as:
Category: Coffee Machines product: luxury espresso machine. variation: fresh milk container
The "coffee machines" category page also lists the variations of other products as filters.. a size 9 rainbow colored coffee machine would be nice, but it doesn't really make sense. did I miss something about this in the episodes? I think it has something to do with [facetsDistribution]?
Product variations basically as trees, is this a common way of doing this? It kinda makes sense but I have not seen it done like this while reviewing ecommerce solutions.
Also, I'm curious to see how that would work in an admin UI/UX wise. Everything is done now directly on the database, but that is not real life. Are you planning to do (some) admin functionality too?
Am getting this error on the ProductBrowser,
Attribute category_ids
is not filterable. Available filterable attributes are: ``. 1:13 category_ids=4
Am using meilisearch v0.25.2
please asist
$options
in $meilisearch->search()
until the fix in episode 36 like so,1$search = Product::search('', function ($meilisearch, string $query, array $options) {2 $options['filter'] = 'category_ids = ' . $this->category->id;34 return $meilisearch->search($query); // dont pass $options5})->get();
Thanks mate
Thank you so much!
Hi Alex, what about 'min' price? When less than min price - all filters disappear. Ep 39 Filtering by price.
ep 29: orderByPivot('id') should be used instead
Hey Alex, I have a problem in class 38.
Error: Call to a member function map() on null (View: /home/ddrummond/Projects/e-commerce/resources/views/categories/show.blade.php)
in this line: ->map(function ($value, $key) { return $value->map(fn ($value) => $key . ' = "' . $value . '" AND'); })
But my code is the same as yours, I've reviewed everything and I'm not finding the problem
I have the same problem as yours, did you solve it?
Accualy I solve it and the problem was the return
1Collection::macro('recursive', function () {2 return $this->map(function ($value) {3 if (is_array($value) || is_object($value)) {4 return collect($value)->recursive();5 }6 return $value;7 });8 });
Add return before ->map.
Hey Alex, when selecting both colors e.g., white and black shouldn't there be both shoes visible?
That would probably be better, yes! Just adjust the Meilisearch query to use OR instead of AND.
Unable to Fetch and show $skuVariant result when selecting color and size. Also no result if using DD on skuVariant. Stuck here on 3:38min on 10. Faking adding the final variation video. Can anyone help me on how to solve this. Thanks.
Hey Deep. Could you put the relevant code in a GitHub Gist and I'll take a look?
Hey Alex, thanks for this course. I was playing around with this and notice that if you have one product in the "New in" category only with one color variation and size this shows the others. Is normal this behaviour? I mean, I think that the live wire component must show the variations related to the product that list.
So, if you select the variation "rainbow" this clear the other 2 variations and if you revert that selection all the variations shows up.
Thanks, I'll check this out and adjust the course with a fix.
Alex, if you haven't already planned on this suggestion I would like to see the browser query string updated with the searched filters so that when you click on a product and then hit the back button, the browser will bring you back to the same search filters. This concept is very important and logical in these kinds of searches.
Thanks for the suggestion. This should be pretty easy to achieve because Livewire has native support for this. I'll schedule in an episode to cover it 👍
Hi, when you use cknow/laravel-money like that, how do you handle price inputs in backoffice? Any advices?
One method of achieving that is to use a Mutator (setter) in your model (in this case Product) like below:
1public function setPriceAttribute($value)2{3 $this->attributes['price'] = $value * 100;4}
So if user entered 50 for price, when the model is saving the record, it will multiply the price by 100, and when you show the price in your views it will show the formatted and expected price.
I hope this helps.
Hi.
After uploading the image, when I call its url, I get 404 as a result. The path is correct and the image is in the folder. Anyone with the same problem, how to solve it?
I managed to solve the problem, I had not created the symlink
php artisan storage:link
Thanks
Glad you sorted it!
php artisan storage:link it tried it doesnt work still cant get it to load but when loading the asset it works
hi not sure why meilisearch returns a error when i try to add the search query. Laravel returns the following;
Attribute category_ids
is not filterable. Available filterable attributes are: ``. 1:13 category_ids = 18
in the meilisearch mini-dashboard the id's are shown as following:
array [ 0:13 1:8 ]
im on laravel 9.0 and meilisearch v0.25.2
hope you can help me out.
As far as I know Meilisearch got updated and now you need to be explicit on which properties are filterable. Laravel Scout however has no way to define these filterable properties. There are some workarounds, but it requires a bit more work. See the Meilisearch documentation for the updateFilterableAttributes method. I got stuck here as well, will have a look tomorrow if I can find a workaround or if downgrading Meilisearch helps.
I got it working with Meilisearch v0.25.2 now. Like I said, recent versions of Meilisearch require you to be explicit about what properties can be filtered. However, Laravel Scout doesn't offer this option. By looking at the documentation of Meilisearch, you can use the updateFilterableAttributes() method for that. This method needs to run at runtime, so I created a ScoutServiceProvide for that and added it in the boot method.
$client = app(Client::class); $client->index('products')->updateFilterableAttributes([ 'category_ids' ]);
Now you can use category_ids as a filter in your ProductBrowser livewire component.
Brilliant! Got it sorted, thanks!!
Thanks for addressing this Marcel! A little later on (ep 36, I think), we explicitly set these, so hopefully it won't cause too much confusion.
Made it to the episode where you use Postman to add these filterable types now, didn't think of that! And although the category_ids are set explicit and you no longer need the serviceprovider for that, you can still use it to add the size and color attributes as well.
Tks! your solution solved my problem
Alex can you do a courses of Laravel/Paypal for this and include in this course please
Hi Alex.
It would be nice if you can push the code being each commit a step.
🙂
AM not sure why my product variation relationship ain't working, I ended up doing this in the selectedVariationModel
return Variation::find($this->selectedVariation)->descendants()->depthFirst()->get();
Also my inline conditional statement aint working too. so I had to remove the "?" in the statement. e.g
From: {{ Str::title($variations->first()?->type) }}
To: {{ Str::title($variations->first()->type) }}
Is there anything am missing in my setup?
I get this error:
syntax error, unexpected '->' (T_OBJECT_OPERATOR) (View: .../resources/views/livewire/product/product-selector.blade.php)
I had the same syntax error and then I upgraded my php to version 8 and its now working
Yep, you'll need > PHP 8 for this course.
Thanks 🙏
Great Course! i'm getting a 404 when loading the image im using homestead/ vagrant any tips on how to get the image displayed properly ?
Have you run
1php artisan storage:link
Yes i did. but it throws a exception :
ErrorException
symlink(): Protocol error
Got it. had to start vagrant as administrator -.-
Ahh brilliant. Glad it's sorted 👍
Awaiting new episodes!!!!!
So what if we need to make this cart in api like form mobile app or react app how we can handle the session ?
I won't be covering the API side in this course, but you could use any API authentication method that Laravel supports and then reference the cart UUID in any requests.
Thank you, so the guest cart in this case will not be in database?
Yep, the guest cart gets stored in the database. When the user authenticates, it's transferred to that authenticated user.
is anybody gettting this error using the Laravel Money package Problem 1 - Root composer.json requires cknow/laravel-money ^1.0 -> satisfiable by cknow/laravel-money[v1.0.0, v1.0.1, v1.0.2, v1.0.3]. - cknow/laravel-money[v1.0.0, ..., v1.0.3] require illuminate/support ~5.1 -> found illuminate/support[v5.1.1, ..., 5.8.x-dev] but these were not loaded, likely because it conflicts with another require.
You can also try re-running composer require with an explicit version constraint, e.g. "composer require cknow/laravel-money:*" to figure out if any version is installable, or "composer require cknow/laravel-money:^2.1" if you know which you need.
I just ended up using the build in money helper form laravel cashier
I have a similar thing when I used Laravel 8, so it worked well. Now I have a similar mistake with Laravel 9.
Problem 1 - Root composer.json requires cknow/laravel-money ^6.2 -> satisfiable by cknow/laravel-money[v6.2.0]. - cknow/laravel-money v6.2.0 requires illuminate/support ^7.0|^8.0 -> found illuminate/support[v7.0.0, ..., 7.x-dev, v8.0.0, ..., 8.x-dev] but these were not loaded, likely because it conflicts with another require.
Problem solved. I used the "akaunting/laravel-money" package. With Laravel 9 it works great.
Thanks Martin, This suggestion worked for me, with Laravel 9, PHP 8.1.2 inside docker.
The "cknow/laravel-money" package has now been updated. He now supports Laravel 9.
Another cool course. Alex, how to implement if some product not have any variations???
In that case you'd just have to add a single variation for the product. Then, switch around the logic to automatically select the first variation if there's only one. I'll see if I can handle this towards the end of the course 👍
Thank you 👍
Alex how would you do that because I have the same problem changing the logic
Can't wait to get started!. I'm curious do we use Laravel Cashier to handle the payment processing portion??
Yep, we're using Laravel Cashier.
Why not use laravel adjacency list for variations too? It's pretty much the same concept as categories.
That's what we are doing.
Hi, will you provide the source code ?
What SQL client are you using?
Postico (for Postgres)
Oof. As a windows user that is a blow to the gut as it's so pretty. Great course btw, enjoying it.
Really good course!!
Any new videos today?
Great work, Alex. This course will help me a lot. Thank you 🙏
Hi Alex, will this cover any verification at checkout? For example, if two customers are buying the same item with low stock value?
Yes, this is covered! Checks are performed on the cart page and checking out and will flash a message to the user that their cart has changes.
Pretty Amazing course. Will you cover the functionality like deals/sale and discounts, where customers can add coupon codes for certain percentage of discounts later in course?
Not coupons yet, but that's an easy addition later down the line once we're done with the base stuff.
How would you deal with the URLs to make them more SEO friendly? e.g. categories/brands/nike/new-in instead of just /categories/new-in.
Great point Lee, I'll note this down and cover it later on in the course.
This looks amazing, Alex. Will you be making shipping costs dynamic based on destination city or country (i.e. city 1 = $5, city 2 = $10, etc.) ?
Not just yet, perhaps something for later on. Right now, they're just fixed shipping costs.
If you look what alex is doing addnig of the subtotal hes taking this from the variations just add the weight of the product in the variations and do the same thing like this public function weight() { return $this->instance()->variations
1 ->reduce(function ($carry, $variation) {23 return $carry + ($variation->product->weight * $variation->pivot->quantity);4 });5}
on App\Cart\Cart then on the shipping types table put al the weights and names of shipping
The Livewire\Checkout
public function mount(CartInterface $cart) { $weight = $cart->weight();
1 $this->shippingTypes = ShippingType::where('weight', '>', $weight)->first()->get(); 2 3 $this->shippingTypeId = $this->shippingTypes->first()->id; 4 5 if($user = auth()->user()) 6 { 7 $this->accountForm['email'] = $user->email; 8 } 910}
The problem ive got itll bring all the relevent shipping tables down that correspond with weight after the weight it has so if the weight is over 2 it wont bring down les than that weight but its bring down weights that are not needed gott a figure that out
Alex buy the way dont whether you know this but Stripe wont accept certain payments you need to add paypal integration to the course
Awesome Alex! Question though:
Will you be covering displaying/selecting variants with images and/or color options?
Hey Gavin. Did you mean having images attached to each variant (.e.g. when you add White Air Force 1 trainers, it shows a white shoe?). Or did you mean different variations? If it's the latter, you can pretty much add any 'type' of variation you like. It's completely flexible.
Yes, the first one. That's how for instance Amazon and Zalando do it and would be nice to get an idea of how to implement that. For me it's one of those things I just can't get my head around how to do it.
So, in the course we're going to be attaching images to each variant. The image gallery you see in the demo are just two images attached to products. So, when you add/buy a White Air Force 1, you'll see that image in your cart/orders.
Hi, how often will new episodes come out?
Daily
Hey Alex, I have a problem in class 38.
Error: Call to a member function map() on null
in this part:
But my code is the same as yours, I've reviewed everything and I'm not finding the problem.