Dilemma Laravel 5.5 ORM and Database

0

I have a query regarding the logic that I should use to use in production in a real estate system:

In a form charge (itero) the environments:

// ... formulario
@forelse(App\Ambiente::all() as $env)
    <fieldset class="form-group col-md-3">
        <label for="env_{{ $env->id }}" class="control-label">
            {{ $env->name }}
        </label>
        @switch($env->type)
            @case('int')
                <input class="form-control" type="number" min="0" id="env_{{ $env->id }}" name="env_{{ $env->id }}" placeholder="{{ $env->placeholder }}" @if(old('env_{{ $env->id }}')) value="{{ old('env_' . $env->id) }}" @elseif(isset($property)) @endif>
                @break
            @case('tf')
                <label class="switch switch-sm">
                    <input class="form-control" type="checkbox" id="env_{{ $env->id }}" name="env_{{ $env->id }}" @if(old('env_{{ $env->id }}')) value="{{ old('env_' . $env->id) }}" @endif>
                    <span class="slider"></span>
                </label>
                @break
            @default

        @endswitch
    </fieldset>
@empty
    <p>No hay ambientes disponibles. <a href="{{ action('EnvironmentController@create') }}"> Agregar</a></p>
@endforelse
// formulario ...

This is the Ambiente model that has the following structure:

And then where my ignorance goes into action, it's the Propiedad form that is the one that enters all the information.

Option 1: I add a column of type string ambientes that enters each environment separated by comma in the same property.

Option 2: I add another model called ValoresAmbiente that has a structure for example property_id (foreign key to the table properties ) and environment_id (foreign key to environments ) that is added to DB when you create a App \ Property :

What would you suggest? Another option? I appreciate any comments and excuse the ignorance.

    
asked by Maramal 02.01.2018 в 23:24
source

0 answers