Tuesday, March 7, 2017

how to avoid data repetition while insert in laravel

i have data like company has branch in multiple city and each city has company three different offices office1, office2 and office3

Data is like below,

  • company1

    • city1
      • Address of office 1, Address of office 2, Address of office 3
    • city2
      • Address of office 1, Address of office 2, Address of office 3
    • city3
      • Address of office 1, Address of office 2, Address of office 3
  • company2

    • city1
      • Address of office 1, Address of office 2, Address of office 3
    • city2
      • Address of office 1, Address of office 2, Address of office 3
    • city3
      • Address of office 1, Address of office 2, Address of office 3

So i need to validate that once company1 address store for city1 then it should not be stored again database, as well if address of office 1 stored for city1 then it will not be stored again. I used laravel 5.3 version.



via user3649115

Advertisement