Laravel hasMany with a filter

This is more like a recommendation of how to structure my database probably. Basically, I have a model App\Project and I have another model App\Asset.

App\Project hasMany App\Asset:

public function assets() {
   return $this->hasMany('App\Asset');
}

The assets are different images and the assets table has a type column.

So on the page where I actually display the project, what I want to do is to display an image that has original set as a type, as a starting / first image and then have others follow up. (all the assets are optional. not all the projects will have an original image.)

How can I achieve that? Should I filter an array and sort of cut the original out of an array?


Download laravel.hasmany.with.a.filter.zip
Direct Link


Download


Download laravel.hasmany.with.a.filter.zip
Mediafire


Download


Download laravel.hasmany.with.a.filter.zip
Uploadsat


Download

Both comments and pings are currently closed.

Comments are closed.