Skip to content

Instantly share code, notes, and snippets.

@raank
Last active March 7, 2019 14:00
Show Gist options
  • Select an option

  • Save raank/1f9fb0ea0c5785169a974661b33a752d to your computer and use it in GitHub Desktop.

Select an option

Save raank/1f9fb0ea0c5785169a974661b33a752d to your computer and use it in GitHub Desktop.

Revisions

  1. raank renamed this gist Mar 7, 2019. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. raank created this gist Mar 7, 2019.
    18 changes: 18 additions & 0 deletions controller.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    <?php

    class Controller
    {
    public function store(Request $request)
    {
    dd($request->redesSociais); // dumping

    foreach ($request->redesSociais as $index => $rede) {
    // $index = 0, 1, 2
    // $rede = array de campos para cada rede
    foreach ($rede as $key => $value) {
    // $key = instagram, seguidores_instagram
    // $value = url do instagram, id selecionado no select
    }
    }
    }
    }
    17 changes: 17 additions & 0 deletions form.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    <form action="/nova/redesocial" method="POST">
    @csrf
    <input
    type="url"
    class="form-control"
    value="{{ old('redesSociais.1.instagram') }}"
    id="instagram"
    name="redesSociais[1][instagram]"
    placeholder="https://www.instagram.com/">
    <select class="form-control select2" name="redesSociais[1][seguidores_instagram]" style="width: 100%;">
    <option selected>Selecione</option>
    @foreach ($seguidores as $item)
    <option value="{{ $item->id }}" @if(old('redesSociais.1.seguidores_instragram') === $item->id) selected @endif>{{ $item->estimativa_seguidores }}</option>
    @endforeach
    </select>
    </form>