Laravel Excel: Import with Relationships

Sdílet
Vložit
  • čas přidán 5. 09. 2024

Komentáře • 83

  • @intipontt7490
    @intipontt7490 Před 3 lety +9

    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.

    • @wahyusetya172
      @wahyusetya172 Před 2 lety

      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

  • @jannusdomingo5681
    @jannusdomingo5681 Před 3 lety +3

    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! 🍻

    • @LaravelDaily
      @LaravelDaily  Před 3 lety +5

      Added to the to-do list, will come up with some useful angle about joins

    • @jannusdomingo5681
      @jannusdomingo5681 Před 3 lety +1

      @@LaravelDaily Thank you so much my fav tutor here! We're excited! 🍻😊

    • @intipontt7490
      @intipontt7490 Před 3 lety +1

      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.

    • @jannusdomingo5681
      @jannusdomingo5681 Před 3 lety

      @@intipontt7490 yeah but we do not know where to start on how to convert our joins in to eloquent

    • @LaravelDaily
      @LaravelDaily  Před 3 lety

      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

  • @digantakrdas8258
    @digantakrdas8258 Před 3 lety +4

    Please provide an example if we need to import to multiple database tables from one CSV file.

  • @user-pn3hk2tn8d
    @user-pn3hk2tn8d Před 3 lety +5

    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

    • @LaravelDaily
      @LaravelDaily  Před 3 lety +1

      Valid points, maybe it would speed up even more, haven't tried.

  • @kirilllubynets8592
    @kirilllubynets8592 Před 2 lety +1

    Very thanks for your video.
    hellow from Ukraine

  • @3rkan0zturk
    @3rkan0zturk Před 10 měsíci

    Awesome, thank you👏

  • @andrewjackson3890
    @andrewjackson3890 Před rokem

    Very useful for me, thank you!!!

  • @gurramkondabhargav8340

    Great sir,
    At a time It will insert to Two different DB's

  • @ImamAdiNata
    @ImamAdiNata Před 2 lety +2

    how about importing one excel file into 2 tables in database?

  • @Gosa-li1ei
    @Gosa-li1ei Před rokem

    Thanks so much Dear Sir.

  • @roselfrancisco1463
    @roselfrancisco1463 Před 2 lety

    The best tutorial as always!

  • @jonathanoeijoeng
    @jonathanoeijoeng Před 2 lety

    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

  • @phanirajk9144
    @phanirajk9144 Před 3 lety

    Thanks a lot. It is really helpful.

  • @shelderrr
    @shelderrr Před 3 lety +1

    What about pivot tables?

  • @ammarqureshi4887
    @ammarqureshi4887 Před 3 lety +1

    Thankyoy can make how get separate array like laravel relationship with inner joins .

  • @majid_alsaidi
    @majid_alsaidi Před 2 lety +1

    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?

  • @oimso
    @oimso Před 3 lety +1

    Nice Video, How to export two or more queries to excel?

  • @abedshamia8094
    @abedshamia8094 Před 2 lety +1

    What if there were no similar column names, and the only relatable column was user_id? :/

  • @surflaweb
    @surflaweb Před 3 lety

    Great example!!

  • @zineddineabdellatif4837

    greate like always

  • @pkeerthana723
    @pkeerthana723 Před rokem

    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.

  • @devaes
    @devaes Před 3 lety

    good timing ! thank you sir

  • @NathanBudd
    @NathanBudd Před 3 lety +1

    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?

    • @rolandosanches2344
      @rolandosanches2344 Před 3 lety

      You can add then to users collection, using prepend() or push() method

  • @hamzaashraf9529
    @hamzaashraf9529 Před 2 lety

    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).

  • @kanzuleman4906
    @kanzuleman4906 Před 2 lety

    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?

  • @fabrizziomorenor.6495
    @fabrizziomorenor.6495 Před 2 lety

    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

  • @aungchanoo8682
    @aungchanoo8682 Před 3 lety +1

    Can you show us how to import images from excel file?

  • @bamswisnu4823
    @bamswisnu4823 Před rokem

    why im running local 'error undefined index: amount' ? please help solving

  • @thedream8420
    @thedream8420 Před rokem

    Sir do you have a video of multi sheet excel import in database in different tables?

  • @webpakistan9589
    @webpakistan9589 Před 3 lety +2

    what if we need to export 500000 rows?

    • @PsyHooZ
      @PsyHooZ Před 3 lety +1

      with DB already includes a tons of users... with User::all() your memory say: "OK, I'm out" ?

    • @Remls
      @Remls Před 3 lety +1

      @@PsyHooZ Just download more memory, ez
      /j

    • @popelyshyn
      @popelyshyn Před 3 lety

      Chunks?!

    • @SeyedSadeghAtaii
      @SeyedSadeghAtaii Před 3 lety

      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.

  • @akichoe
    @akichoe Před 2 lety

    hi.. can i get simple import with multiple start and end date per id? example; one id have many start and end date.

  • @Anonymouseab
    @Anonymouseab Před 2 lety

    hi bro thanks really too it is helpful but i am getting this error bro
    Trying to get property 'id' of non-object

  • @BoiteSphinx
    @BoiteSphinx Před 3 lety

    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?

  • @yogeshwarbarai9686
    @yogeshwarbarai9686 Před rokem

    The file needs to be in csv is mandatory or it can also work with xlsx extension type?

    • @LaravelDaily
      @LaravelDaily  Před rokem +1

      Should work with xlsx too, but try it out.

  • @jahanzaibhussain7598
    @jahanzaibhussain7598 Před 3 lety

    just a big wow!

  • @GergelyCsermely
    @GergelyCsermely Před 3 lety

    Thanks

  • @bibhasash7371
    @bibhasash7371 Před 2 lety

    how to configure header columns with column names having space between like fist name

  • @Antonius77
    @Antonius77 Před 2 lety +1

    А что если отношения Many to Many через pivot таблицу?!

  • @marcinrobertkazmierczak

    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 :) ?

    • @LaravelDaily
      @LaravelDaily  Před 2 lety

      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

  • @tech.business-agencedigita4820

    I have this error : Failed to open stream: Permission denied

  • @sarojguragain554
    @sarojguragain554 Před 3 lety

    Sir, How to use laravel Log with slack in localhost.

  • @noplay6360
    @noplay6360 Před 3 lety

    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.

    • @LaravelDaily
      @LaravelDaily  Před 3 lety

      Planning inertia content a bit later on the channel, not sure why

  • @_fajarsetianto
    @_fajarsetianto Před 3 lety

    How to validate that excel file for each row before saving into database?

    • @LaravelDaily
      @LaravelDaily  Před 3 lety

      I have a video about it: czcams.com/video/pshvWCCyCGw/video.html

  • @pondokkoding5023
    @pondokkoding5023 Před 2 lety

    how to register in your course? there is no register button in your website

    • @LaravelDaily
      @LaravelDaily  Před 2 lety

      You need to purchase that course, there's no "register" button, there's "buy" button.

    • @pondokkoding5023
      @pondokkoding5023 Před 2 lety

      @@LaravelDaily okey have done

    • @pondokkoding5023
      @pondokkoding5023 Před 2 lety

      how to import db3 file into database in laravel, Sir?

  • @konstruktion
    @konstruktion Před 3 lety

    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
      @LaravelDaily  Před 3 lety

      $user = User::create()
      auth()->login($user);
      Or do you really need a video about it?

    • @konstruktion
      @konstruktion Před 3 lety

      ​@@LaravelDaily
      $user = User::factory()->create();
      auth()->login($user);
      $response = $this->get('/clients');
      $response->assertStatus(200);
      Not working, because is not so simple. :(

    • @LaravelDaily
      @LaravelDaily  Před 3 lety

      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.

  • @Roy-xd5mw
    @Roy-xd5mw Před 3 lety

    How to export image in excel with other data

    • @LaravelDaily
      @LaravelDaily  Před 3 lety

      Why would you want to export images into excel? Excel is not typically used for storing images.

    • @Roy-xd5mw
      @Roy-xd5mw Před 3 lety

      @@LaravelDaily if we use js script we can easy export images So, why not with laravel sir ?

    • @Roy-xd5mw
      @Roy-xd5mw Před 3 lety

      Please guide or make some video in which we can easily export images with other data from table

    • @LaravelDaily
      @LaravelDaily  Před 3 lety +1

      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.

    • @oimso
      @oimso Před 3 lety

      Maybe this will help you.
      czcams.com/video/VUet2wq22-o/video.html

  • @hamzaashraf9529
    @hamzaashraf9529 Před 2 lety

    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!

  • @adiputra-og9qt
    @adiputra-og9qt Před 2 lety

    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.