Using lazycollection in the constructor by rewriting the query as User::select('id', 'name', 'email')->cursor()->remember() could save you some memory. Considering imports can be often pretty large, a good idea is to use chunk reading in laravel excel (even if you don't need it at first) to prevent scaling issues.
i dont find in the laravel docs about how much time this cache will be stored, since the data can be dynamic, i think this approach is not the best idea
We've been struggled on understanding the eloquent query I mean the Joins. I had the idea of you making a tuts on what the left joins & inner joins means in Eloquent, I mean you show us the old way and then convert it in eloquent way. Btw all your tuts help us a lot! 🍻
joins don't work differently in eloquent. Unless you mean relationships, but those are not joins at all most of the time. You can dump the query to inspect the generated sql.
Can you email me povilas@laraveldaily.com a few examples of such joins? Then I may try to convert them in the video, would be the most practically useful for everyone. @Jannus Domingo
Have you compared the speed of the database selects with the speed of the collection search? If there are many users, the collection search should be longer. The second question: it might be more optimal to translate the collection of users into an array, where the key is an email. Then the substitution of user IDs would occur instantly
Hi, your channel is helping me a lot to understand laravel better. Regarding to import from csv file, is it possible to import sheet into multiple tables? Thanks so much
I have for example a user table and role table. The relation is hasMany with a pivote table between them. there is no actual column between the two tables. can we import users from csv witht the role id?
while i am doing the same as you are but it is giving me error that undefined index title, title is present in my role class which is actually in relation with the user class one user has one role how can i fix that?
Exist a way i can read the heading row and import in every row imported. Example CARS column..import and set in a column name category...put the CARS string.??? :P
What about if the `user_id` is a non-nullable foreign key? I realise that we could do `firstOrCreate`, but how do you then update the `users` in the constructor?
Thanks for your video! How should I use a trait if i'm workng with multiple sheets. In my app i have multiple sheets, most of them have a manufacturer. Right now I use a trait that fetches the manufacturer based on its name, but everytime i switch sheet, the trait's constructor gets called, how can I limit database interractions with such layout?
Hello Povilas. I'm your student :) I have bought your Laravel Excel course. What if I'm importing file for example with books, and I have some authors which are not present in database? How to add those missing authors in one import and sync them to books via pivot table :) ?
It's been a while since I worked with Excel import, so I don't really remember. Googled a bit, found a few resources: laracasts.com/discuss/channels/laravel/laravel-excel-import-csv-data-relationed-to-another-table github.com/SpartnerNL/Laravel-Excel/issues/1966
Hey Povilas What are your thoughts about inertia with vue and laravel backend? I haven't seen a video about inertia on your channel. So currently I'm thinking about learning livewire, but looking at performance, idk if it's any better than intertia + vue.
Can you make a video where you explain how to write a method in the test that creates (Jetstream) a user via Factory and logs in with that. At Laracasts I only got "it's so simple" answer and thus not helpful. 🙏🏻🙏🏻🙏🏻
@@LaravelDaily $user = User::factory()->create(); auth()->login($user); $response = $this->get('/clients'); $response->assertStatus(200); Not working, because is not so simple. :(
Then it's something with the logic of your application and why it doesn't return 200. Maybe it returns 403 because of some permissions? Not sure, needs debugging.
Sorry I don't have any examples of images, I just personally haven't encountered excel files that would contain images, in my opinion Excel files are for calculations and data, not for images. Please read the official docs of Laravel Excel package, maybe they will have something.
i'm sorry but your prices are too high 29$,99$ in pakistan 99$ equals to 17,127.49 Pakistani Rupee. 17 thousand no one wants to pay please consider this point. we want to learn quality code but not in this price we can't afford thanks!
why i can't run composer require maatwebsite/excel in my computer? this is my error: Your requirements could not be resolved to an installable set of packages. Problem 1 - maatwebsite/excel[3.1.36, ..., 3.1.x-dev] require phpoffice/phpspreadsheet ^1.18 -> satisfiable by phpoffice/phpspreadsheet[1.18.0, ..., 1.24.1]. - maatwebsite/excel[3.1.0, ..., 3.1.25] require php ^7.0 -> your php version (8.1.6) does not satisfy that requirement. - maatwebsite/excel[3.1.26, ..., 3.1.35] require illuminate/support 5.8.*|^6.0|^7.0|^8.0 -> found illuminate/support[v5.8.0, ..., 5.8.x-dev, v6.0.0, ..., 6.x-dev, v7.0.0, ..., 7.x-dev, v8.0.0, ..., 8.x-dev] but these were not loaded, likely because it conflicts with another require. - phpoffice/phpspreadsheet[1.18.0, ..., 1.24.1] require ext-gd * -> it is missing from your system. Install or enable PHP's gd extension. - Root composer.json requires maatwebsite/excel ^3.1 -> satisfiable by maatwebsite/excel[3.1.0, ..., 3.1.x-dev]. To enable extensions, verify that they are enabled in your .ini files: You can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode. Alternatively, you can run Composer with `--ignore-platform-req=ext-gd` to temporarily ignore these required extensions. You can also try re-running composer require with an explicit version constraint, e.g. "composer require maatwebsite/excel:*" to figure out if any version is installable, or "composer require maatwebsite/excel:^2.1" if you know which you need.
Using lazycollection in the constructor by rewriting the query as User::select('id', 'name', 'email')->cursor()->remember() could save you some memory. Considering imports can be often pretty large, a good idea is to use chunk reading in laravel excel (even if you don't need it at first) to prevent scaling issues.
i dont find in the laravel docs about how much time this cache will be stored, since the data can be dynamic, i think this approach is not the best idea
We've been struggled on understanding the eloquent query I mean the Joins. I had the idea of you making a tuts on what the left joins & inner joins means in Eloquent, I mean you show us the old way and then convert it in eloquent way. Btw all your tuts help us a lot! 🍻
Added to the to-do list, will come up with some useful angle about joins
@@LaravelDaily Thank you so much my fav tutor here! We're excited! 🍻😊
joins don't work differently in eloquent. Unless you mean relationships, but those are not joins at all most of the time. You can dump the query to inspect the generated sql.
@@intipontt7490 yeah but we do not know where to start on how to convert our joins in to eloquent
Can you email me povilas@laraveldaily.com a few examples of such joins? Then I may try to convert them in the video, would be the most practically useful for everyone. @Jannus Domingo
Very thanks for your video.
hellow from Ukraine
Great sir,
At a time It will insert to Two different DB's
Please provide an example if we need to import to multiple database tables from one CSV file.
Very useful for me, thank you!!!
Have you compared the speed of the database selects with the speed of the collection search? If there are many users, the collection search should be longer. The second question: it might be more optimal to translate the collection of users into an array, where the key is an email. Then the substitution of user IDs would occur instantly
Valid points, maybe it would speed up even more, haven't tried.
Awesome, thank you👏
The best tutorial as always!
Thanks so much Dear Sir.
Hi, your channel is helping me a lot to understand laravel better. Regarding to import from csv file, is it possible to import sheet into multiple tables? Thanks so much
I have for example a user table and role table. The relation is hasMany with a pivote table between them. there is no actual column between the two tables. can we import users from csv witht the role id?
Is there any way to validate unique email when emails are stored in database as encrypted data and display error message row wise in blade file.
Nice Video, How to export two or more queries to excel?
Sir do you have a video of multi sheet excel import in database in different tables?
No
Thanks a lot. It is really helpful.
why im running local 'error undefined index: amount' ? please help solving
how about importing one excel file into 2 tables in database?
What would be an example use case for such a feature ?
while i am doing the same as you are but it is giving me error that undefined index title, title is present in my role class which is actually in relation with the user class one user has one role how can i fix that?
Thankyoy can make how get separate array like laravel relationship with inner joins .
hi bro thanks really too it is helpful but i am getting this error bro
Trying to get property 'id' of non-object
hi.. can i get simple import with multiple start and end date per id? example; one id have many start and end date.
What about pivot tables?
The file needs to be in csv is mandatory or it can also work with xlsx extension type?
Should work with xlsx too, but try it out.
Exist a way i can read the heading row and import in every row imported. Example CARS column..import and set in a column name category...put the CARS string.???
:P
Great example!!
how to configure header columns with column names having space between like fist name
What about if the `user_id` is a non-nullable foreign key?
I realise that we could do `firstOrCreate`, but how do you then update the `users` in the constructor?
You can add then to users collection, using prepend() or push() method
Can you show us how to import images from excel file?
Thanks for your video!
How should I use a trait if i'm workng with multiple sheets.
In my app i have multiple sheets, most of them have a manufacturer. Right now I use a trait that fetches the manufacturer based on its name, but everytime i switch sheet, the trait's constructor gets called, how can I limit database interractions with such layout?
and it would be great if you add a button under your course like send offer (someone can offer you a buy price for every single course).
What if there were no similar column names, and the only relatable column was user_id? :/
good timing ! thank you sir
greate like always
А что если отношения Many to Many через pivot таблицу?!
Hello Povilas. I'm your student :) I have bought your Laravel Excel course. What if I'm importing file for example with books, and I have some authors which are not present in database? How to add those missing authors in one import and sync them to books via pivot table :) ?
It's been a while since I worked with Excel import, so I don't really remember. Googled a bit, found a few resources:
laracasts.com/discuss/channels/laravel/laravel-excel-import-csv-data-relationed-to-another-table
github.com/SpartnerNL/Laravel-Excel/issues/1966
Thanks
Hey Povilas
What are your thoughts about inertia with vue and laravel backend? I haven't seen a video about inertia on your channel.
So currently I'm thinking about learning livewire, but looking at performance, idk if it's any better than intertia + vue.
Planning inertia content a bit later on the channel, not sure why
Sir, How to use laravel Log with slack in localhost.
I have this error : Failed to open stream: Permission denied
how to register in your course? there is no register button in your website
You need to purchase that course, there's no "register" button, there's "buy" button.
@@LaravelDaily okey have done
how to import db3 file into database in laravel, Sir?
just a big wow!
How to validate that excel file for each row before saving into database?
I have a video about it: th-cam.com/video/pshvWCCyCGw/w-d-xo.html
what if we need to export 500000 rows?
with DB already includes a tons of users... with User::all() your memory say: "OK, I'm out" ?
@@PsyHooZ Just download more memory, ez
/j
Chunks?!
It's a good point but if you check the premium course he provides, or the documentation for laravel excel it should be all you need to know.
Can you make a video where you explain how to write a method in the test that creates (Jetstream) a user via Factory and logs in with that. At Laracasts I only got "it's so simple" answer and thus not helpful. 🙏🏻🙏🏻🙏🏻
$user = User::create()
auth()->login($user);
Or do you really need a video about it?
@@LaravelDaily
$user = User::factory()->create();
auth()->login($user);
$response = $this->get('/clients');
$response->assertStatus(200);
Not working, because is not so simple. :(
Then it's something with the logic of your application and why it doesn't return 200. Maybe it returns 403 because of some permissions? Not sure, needs debugging.
How to export image in excel with other data
Why would you want to export images into excel? Excel is not typically used for storing images.
@@LaravelDaily if we use js script we can easy export images So, why not with laravel sir ?
Please guide or make some video in which we can easily export images with other data from table
Sorry I don't have any examples of images, I just personally haven't encountered excel files that would contain images, in my opinion Excel files are for calculations and data, not for images. Please read the official docs of Laravel Excel package, maybe they will have something.
Maybe this will help you.
th-cam.com/video/VUet2wq22-o/w-d-xo.html
i'm sorry but your prices are too high 29$,99$ in pakistan 99$ equals to 17,127.49 Pakistani Rupee. 17 thousand no one wants to pay please consider this point. we want to learn quality code but not in this price we can't afford thanks!
Visit coupons.laraveldaily.com
why i can't run composer require maatwebsite/excel in my computer?
this is my error:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- maatwebsite/excel[3.1.36, ..., 3.1.x-dev] require phpoffice/phpspreadsheet ^1.18 -> satisfiable by phpoffice/phpspreadsheet[1.18.0, ..., 1.24.1].
- maatwebsite/excel[3.1.0, ..., 3.1.25] require php ^7.0 -> your php version (8.1.6) does not satisfy that requirement.
- maatwebsite/excel[3.1.26, ..., 3.1.35] require illuminate/support 5.8.*|^6.0|^7.0|^8.0 -> found illuminate/support[v5.8.0, ..., 5.8.x-dev, v6.0.0, ..., 6.x-dev, v7.0.0, ..., 7.x-dev, v8.0.0, ..., 8.x-dev] but these were not loaded, likely because it conflicts with another require.
- phpoffice/phpspreadsheet[1.18.0, ..., 1.24.1] require ext-gd * -> it is missing from your system. Install or enable PHP's gd extension. - Root composer.json requires maatwebsite/excel ^3.1 -> satisfiable by maatwebsite/excel[3.1.0, ..., 3.1.x-dev].
To enable extensions, verify that they are enabled in your .ini files:
You can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode.
Alternatively, you can run Composer with `--ignore-platform-req=ext-gd` to temporarily ignore these required extensions.
You can also try re-running composer require with an explicit version constraint, e.g. "composer require maatwebsite/excel:*" to figure out if any version is installable, or "composer require maatwebsite/excel:^2.1" if you know which you need.