How to generate custom ID in Laravel - Laravel ID generator

Sdílet
Vložit
  • čas přidán 21. 11. 2019
  • In this video, I have shown you how to generate custom ID in Laravel Framework with Laravel ID generator package.
    For more example please visit: laravelarticle.com/laravel-cu...
    #Laravel #IdGenerator

Komentáře • 47

  • @isaacboakye-manu7454
    @isaacboakye-manu7454 Před 4 lety +2

    I love it. Very Simple and easy to implement. Thanks

  • @mochamadhadyonosandi2085

    thanks dude it help me so mucc i hope i can run this method on laravel 8

  • @EmiratesVibes
    @EmiratesVibes Před 4 lety

    hey your video is great but I am inserting multiple data to the database at the same time and i would like all of them to have same id.How can I go about it?

  • @codebuilders9081
    @codebuilders9081 Před 4 lety +2

    thanks

  • @dewagedeadityaputra4316

    I got error, i want to insert in Orders table not User table, but the errors say “column not found unknow trx(field for keep and save id generator) in where clause “ SELECT count* As aggregate From Users where trx

  • @warongrat28
    @warongrat28 Před 4 lety

    how to use with multiple databases ?

  • @muhammadwavarasyadi2927
    @muhammadwavarasyadi2927 Před 4 lety +1

    how can I make that auto restart at 1 when the new year?

    • @LaravelArticle
      @LaravelArticle  Před 4 lety

      On prefix change reset id support added (v1.0.5). Please check the documentation. laravelarticle.com/laravel-custom-id-generator

  • @JayRagnamTV
    @JayRagnamTV Před 4 lety +1

    hi how about i need to put the unique generated ID from the other column, it always going to the id column

    • @LaravelArticle
      @LaravelArticle  Před 4 lety

      Check out latest relaese.

    • @JayRagnamTV
      @JayRagnamTV Před 4 lety +1

      link please?

    • @LaravelArticle
      @LaravelArticle  Před 4 lety

      v1.0.4
      github.com/haruncpi/laravel-id-generator

    • @JayRagnamTV
      @JayRagnamTV Před 4 lety

      @@LaravelArticle how to fix A non-numeric value encountered

    • @LaravelArticle
      @LaravelArticle  Před 4 lety

      @@JayRagnamTV If your id mix with string+digit then your field data type must be varchar

  • @rkdasaris6247
    @rkdasaris6247 Před 4 lety +1

    i got the error when i go for the next increment like INV-00002 shows A non-numeric value encountered

    • @LaravelArticle
      @LaravelArticle  Před 4 lety

      Please make sure your field type is varchar according to your id format.

    • @riandemonfox8880
      @riandemonfox8880 Před 4 lety

      @@LaravelArticle i have an error like that too, and my field type is varchar, but still got that error, how i can fix this??

    • @dogoier9125
      @dogoier9125 Před 3 lety

      @@riandemonfox8880 i got that too, pls reply

  • @JuanMoreno-je7rv
    @JuanMoreno-je7rv Před 4 lety +1

    how to use with postgresql

  • @dogoier9125
    @dogoier9125 Před 3 lety

    there's an error after storing data for the first time, the second tim i got error A non-numeric value encountered

    • @dogoier9125
      @dogoier9125 Před 3 lety

      i already fixed this, when i use length = 4 i encountered the error. try change the length to 10 (maybe 6 work as well)

  • @levitheackerman1481
    @levitheackerman1481 Před 4 lety

    Exception
    table field type is bigint but prefix is string
    how to fix it? when i change type data id integer to varchar : error mysql

    • @LaravelArticle
      @LaravelArticle  Před 4 lety

      Please let me know, what is your id format and field type?

    • @levitheackerman1481
      @levitheackerman1481 Před 4 lety +1

      @@LaravelArticle id, bigint, 11, AI, primary

    • @LaravelArticle
      @LaravelArticle  Před 4 lety

      Don't use AI, if your field type int then do not use id formation like INV-10001 or 100-4667 or P-0001. Please let me know what is your expected id format.

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

      @@LaravelArticle but I also have an error like that, I have tried to use type string / char / text but still get the error "table field type is bigint but prefix is string", like this stackoverflow.com/questions/65642455/idgenerator-laravel-8-how-to-fix-exception-table-field-type-is-bigint-but-pref
      help me, thanks

    • @LaravelArticle
      @LaravelArticle  Před 3 lety

      @@yahikkonr6350 By default it uses id column. Your solution is given stackoverflow.com/questions/65642455/idgenerator-laravel-8-how-to-fix-exception-table-field-type-is-bigint-but-pref/65643282#65643282

  • @MuhammadHaris-kp1oe
    @MuhammadHaris-kp1oe Před 3 lety

    hi! its really helpful, butt there is a problem. it generate same id everytime.

    • @MuhammadHaris-kp1oe
      @MuhammadHaris-kp1oe Před 3 lety

      $config = [
      'table' => 'visitor',
      'length' => 9,
      'prefix' => date('y')
      ];
      return $vid = IdGenerator::generate($config);
      MY CODE

  • @urufu
    @urufu Před 4 lety +1

    how i can use restart every year but i need this output: 0001-2020
    Code: $id = IdGenerator::generate(['table' => 'orders','field'=>'c_interno', 'length' => 9, 'prefix' =>date('-Y'),'reset_on_prefix_change'=>true]);

    • @LaravelArticle
      @LaravelArticle  Před 4 lety

      You can't. Doable 2020-0001

    • @anisawadi3453
      @anisawadi3453 Před 2 lety

      do u find any solution??

    • @urufu
      @urufu Před 2 lety

      ​@@anisawadi3453 i save $id_generate = IdGenerator::generate(['table' => 'orders','field'=>'c_interno', 'length' => 9, 'prefix' =>date('-Y'),'reset_on_prefix_change'=>true]);
      and for show in view
      $id_generate = explode('-',$order->c_interno);
      $codigo = $id_generate[1];
      $year = $id_generate[0];

  • @wanprogrammer9378
    @wanprogrammer9378 Před 3 lety

    This is not working with Laravel 8

    • @wanprogrammer9378
      @wanprogrammer9378 Před 3 lety

      Is there any way that this package can work with Laravel 8 ?

    • @LaravelArticle
      @LaravelArticle  Před 3 lety

      Not working is not enough message about it’s working or not. Let us know what you are tring and what's the actual error with clear example code in GitHub issue.

    • @jubayeralamrana217
      @jubayeralamrana217 Před 3 lety

      @@LaravelArticle I am also facing this issue with laravel 8. It's not incrementing the same value are inserting in the database table. is there are any way to work with laravel 8.

    • @LaravelArticle
      @LaravelArticle  Před 3 lety

      Please try the latest version of Laravel ID generator

    • @mtskz
      @mtskz Před 3 lety

      @@LaravelArticle Hello, this package doesnt work correctly in Laravel 8. I doesnt get the max ID value from the id table. It creates values with ids from 1-10 and then it starts from 1 again. Example: 210001, 210002,210003,...,210010,210001,210002. I needed a custom ID field in the db and I would like to use the unique ID value of every row to create such and id but its not creating unique values. I'm using the latest version.