Skip to content

Instantly share code, notes, and snippets.

@raank
Last active March 7, 2019 22:59
Show Gist options
  • Save raank/d9f1ec3b1f43d6163d5fa82082b54d36 to your computer and use it in GitHub Desktop.
Save raank/d9f1ec3b1f43d6163d5fa82082b54d36 to your computer and use it in GitHub Desktop.
<?php
class Controller
{
public function index()
{
return view('home', [
'seguidores' => [
'instagram' => ''// query para inseriros seguidores do instagram
'facebook' => ''// query para inseriros seguidores do facebook
]
]);
public function store(Request $request)
{
foreach ($request->redesSociais as $rede => $values) {
$rede = new RedesSociais();
$rede->tipo_redes_id = 1;
$rede->url = $values['url_rede'];
$rede->descricao = "Teste";
$rede->seguidores_influenciadores_id = $values['seguidores_rede'];
// save
$influenciadores->redes()->save($rede);
}
}
}
<form action="/nova/redesocial" method="POST">
@csrf
@php
$redes = ['intagram', 'facebook'];
@endphp
@foreach($redes as $rede)
<input
type="url"
class="form-control"
value="{{ old(sprintf('redesSociais.%s.url_rede', $rede)) }}"
id="url_{{ $rede }}"
name="{{ sprintf('redesSociais[%s][url_rede]', $rede) }}"
placeholder="Digite a URL do {{ ucfirst($rede) }}">
<select class="form-control select2" name="{{ sprintf('redesSociais[%s][seguidores_rede]', $rede) }}" style="width: 100%;">
<option selected>Selecione</option>
@foreach ($seguidores[$rede] as $item)
<option value="{{ $item->id }}" @if(old(sprintf('redesSociais.%s.seguidores_rede', $rede)) === $item->id) selected @endif>{{ $item->estimativa_seguidores }}</option>
@endforeach
</select>
@endforeach
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment