Similar strings in a model (PHP laravel)

I am currently working on eloquent models, and I have a model TheSeries, and I would like to display similar series based on the model TheGenres.

Where do you think this should be done between the controller or model in Laravel?

Can you help me give some sample code, so I can figure out how to return similar strings based on genreID / genreName from TheGenres. Thank.

I need the same query, but in Laravel \ Eloquent way:

SELECT m2.* FROM mSeriesGenres m1 

    INNER JOIN mSeriesGenres m2 
        ON m1.genreID = m2.genreID 
    JOIN TheSeries m3 
        ON m3.id = m1.seriesID 

WHERE m1.seriesID = 13 AND m2.seriesID <> 13
GROUP BY m2.seriesID HAVING COUNT(*) = (SELECT COUNT(*) FROM mSeriesGenres WHERE seriesID = 13)

I would like to point out that mSeriesGenres is a many-to-many table.

+4
source share
1 answer

You can try the approach to the repository template:

https://bosnadev.com/2015/03/07/using-repository-pattern-in-laravel-5/

+1
source

Source: https://habr.com/ru/post/1663621/


All Articles