I try to extract the number from the dictionary value but I can't get it as the int I need.
print(contador['Attributes'])
#Respuesta
{'ApproximateNumberOfMessages': '30'}
print(contador['Attributes'].values())
#Respuesta
dict_values(['30'])
I try to extract the number from the dictionary value but I can't get it as the int I need.
print(contador['Attributes'])
#Respuesta
{'ApproximateNumberOfMessages': '30'}
print(contador['Attributes'].values())
#Respuesta
dict_values(['30'])
I am sending an email through a form and it works fine.
I have the problem in the validation, that when it is not fulfilled, either because I do not fill in a field, etc; it redirects me to the page and I have to scroll down to the form to see the error fields displayed.
How could I put the block before, so that if it does not comply with the validation that I put, it does not execute the sending yet, it does not try to send the mail and it refreshes the page with the errors, but not the whole one?
Controller :
public function store(FormInfoImaginarq $request)
{
if($validated = $request->validated()){
Mail::to('[email protected]')->send(new InfoImaginarq($request));
return redirect('/#contacto');
} else {
return redirect('/#contacto');
}
}
FormRequest :
public function rules()
{
return [
'name' => 'required',
'email' => 'required|email',
'message' => 'required',
];
}
Form in the View :
{{ Form::open(['method' => 'post' , 'route' => 'infocontacto']) }}
<div class="row">
<div class="input-field col s12">
<i class="material-icons prefix">account_circle</i>
{{ Form::label('name', 'Introduce tu nombre', ['class' => 'icon_prefix', 'required' => 'required']) }}
{{ Form::text('name') }}
@if ($errors->has('name'))
<small class="form-text text-danger">{{ $errors->first('name') }} </small>
@endif
</div>
</div>
<div class="row">
<div class="input-field col s12">
<i class="material-icons prefix">email</i>
{{ Form::label('email', 'Introduzca su email', ['class' => 'icon_prefix1', 'required' => 'required']) }}
{{ Form::email('email') }}
@if ($errors->has('email'))
<small class="form-text text-danger">{{ $errors->first('email') }} </small>
@endif
</div>
</div>
<div class="row">
<div class="input-field col s12">
<i class="material-icons prefix">mode_edit</i>
{{ Form::label('message', 'Escriba su mensaje', ['class' => 'icon_prefix2', 'required' => 'required']) }}
{{ Form::text('message') }}
@if ($errors->has('message'))
<small class="form-text text-danger">{{ $errors->first('message') }} </small>
@endif
</div>
</div>
<div class="center-align">
{{ Form::button('<i class="material-icons right">send</i> Enviar', ['type' => 'submit', 'class' => 'btn waves-effect waves-light deep-purple lighten-2 yellow-text text-accent-1']) }}
</div>
{{ Form::close() }}
Hi, let's see if you can give me a hand with this that still confused me a bit with these loops and I'm starting in python, I'm reading a directory with 20 .txt files the idea is to open each file and add a text to each one and that the 20 files have that text and once the modification is done, saving each file again would have to obtain another 20 other files with the phrase already added. I've already got stuck in this part, it's what I have written for now, also the part of saving the file, but I can't make it in a loop either so that the modification closes one by one. I can only do it individually.
import glob
import re
import os
os.chdir("Prueba/")
for file in glob.glob("*.txt"):
print(file)
f = open(file, 'r', encoding='utf-8-sig')
save = f.read()
print(save)
f.close()
I want to do a foreach of two lists but that in each line it tells me:
Tengo 5 Naranjas
Tengo 6 Peras
Tengo 2 Platanos
I can't find the way and it must be pretty silly to do it but I'm starting with python.
items = ['naranjas', 'peras', 'platanos']
nums = [5, 6, 2]
# without indexes
for item in items:
print("Tengo" + str(nums) + str(items))
Hello, I am doing some tests in which I intend to go through some forms with various texts, in which I manage to get the information correctly, but when it comes to modifying and saving it, it is not doing it correctly, I leave you part of the code.
Controller
public function update(Request $request, $id)
{
//
$textos=Texto::findOrFail($id);
$textos->update($request->all());
$textos->save();
Toastr::success("Se ha actualizado correctamente la $textos->texto");
return Redirect::to('entradas');
}
View
<section class="content">
<div class="row">
<div class="box-header with-border">
<h3 class="box-title">Editar Textos</h3>
</div>
@foreach($textos as $listado)
<div class="col-md-6">
<div class="box box-primary">
{{ Form::model($listado, ['method' => 'post' , 'files' => true , 'route' => ['entradas.update',$listado->id]]) }}
@method('PUT')
<div class="form-group">
{{ Form::label('texto', 'Texto') }}
{{ Form::textarea('texto', $listado->texto, array("class" =>"form-control")) }}
</div>
<div class="box-footer">
{{ Form::submit('Guardar', array("class" => "btn btn-primary")) }}
{{ Form::reset('Reset', array("class" => "btn btn-primary")) }}
</div>
</div>
</div>
@endforeach
</div>
</section>
Good, I'm trying to go through a foreach that I have separated by categories where I show brief descriptions of each category inside. The title always gives me the same title and I can't go through it correctly. I leave you the code so you can take a look at what it is failing me that there will be several things for sure.
<div class="row">
@foreach($categoria as $listado1)
<div class="col xl4 m4 s12">
<div class="card deep-purple lighten-2 z-depth-3">
<div class="card-image waves-effect waves-block waves-light">
<a class="modal-trigger" href="#modal4"><img class="activator" src="http://backend.imaginarqultural.es:81/storage/{{ $listado1->url }}" alt="{{ $listado1->name }}"></a>
</div>
<div class="card-content">
<span class="card-title activator grey-text text-lighten-4">{{ $listado1->titulo }}</span>
</div>
</div>
</div>
@endforeach
<!-- Modal Structure -->
@foreach($categoria as $listado1)
<div id="modal4" class="modal">
<div class="modal-content grey lighten-4">
<h4>{{ $listado1->titulo }}</h4>
@foreach($portfolio as $listado2)
@if($listado2->category_id == $listado1->id)
<p>{{ $listado2->actividad }}, {{ $listado2->lugar }}<p>
@endif
@endforeach
</div>
<div class="modal-footer grey lighten-4">
<a href="#!" class="deep-purple lighten-3 modal-action modal-close waves-effect waves-purple btn-flat yellow-text text-accent-1">Aceptar</a>
</div>
</div>
@endforeach
</div>
</div>