The right way to solve this without much of overhead from PHP and also faster processing would be to create double foreigns of uuid(string) type and create second relation like movieCategoryByUuid where you would specify foreigns as uuid, also you sould put an index on the new foreign for the faster access.
Then you will be able to run your original code in the controller without any changes except for the used relation to create movie_categories.