jeudi 3 décembre 2015

Laravel 5.1 hasMany relation query

I'm trying to develop a simple web-app where I store a farmer's detail and his/her cultivation information.

I have 2 database tables - farmer and farmer_crop.

farmer table
id | name | phone

farmer_crop table
id | farmer_id | farming_location | farming_crop_name | harvest_end_date

I made 2 controllers - FarmerController & FarmerCropController. A Farmer can cultivate many crops so the Farmer has hasMany with FarmerCrop. Now I want to show a list of farmers using the FarmerController's index method where I get farmers who are farming wheat. How do I go about achieving this?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire