Filter Statuses Array

Posted 1 week ago by xtremer360

Hey all I'm trying to figure out what's the best way to go for this situation. The code below is coming from a filter form that allows the user to select any possible status to filter the list of players query. So I'm wondering if it would be worth creating a method for the Player model that returns an array of statuses. These statuses are NOT stored in the database, however, each status has an associated scope inside of the Player model. Another reason why I thought it would be a good idea to create a method that returns the array of possible statuses is that when the user submits the form that can filter by the status I have a validation Rule::in() that has the array of statuses.

What are thoughts on this?

@foreach ($statuses as $status)
    <option value="only_{{ strtolower($status) }}">{{ $status }}</option>
@endforeach 

old version looks like this.

<option value="only_bookable">Bookable</option>
<option value="only_pending_introduction">Pending Introduction</option>
<option value="only_retired">Retired</option>
<option value="only_injured">Injured</option>
<option value="only_suspended">Suspended</option>

Please sign in or create an account to participate in this conversation.