mercredi 16 mars 2016

Laravel eloquent Relationship Query

My database schema is

links:
 id      status        user_id       url
  1         1            1            something
  2         1            1            something
  3         1            1            something

links_type:
 id         link_id      links_type
  1            1            external
  2            1            external
  3            1            internal
  4            1            external
  5            2            internal
  6            2            external
  7            2            internal
  8            2            external

i want to take data of all links which status is 1 and user_id is 1 and count external and internal links and which external count is >2.

by using laravel 5.2 eloquent.

result should be like this from data given

  id     status   user_id     url       external_links     internal_links
   1        1       1       something         3                   1



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire