Hi everyone, I wanted your help in a where.
In my system it is like this, I am on the photo gallery page of the Resort (id = 1), on this page I can register the photos of the month / year of the development (the steps of the work). When I register the photos create a button on the same page with a month / year title (Ex: December / 2014) and if you have it in January it will register the photos from January / 2015. And when I click on this button it is to open a modal with the photos referring only to that month / year (December / 2014) of the project (id = 1).
I managed to do this with Ajax passing the values and returning the photos, but now I have a problem, when I click the button (December 2014), it opens the modal and pulls all the photos of the project with the id = 1, let's say I registered (8 photos in December / 2014) and (6 photos January / 2015) it should pull only the 8 photos in December / 2014 and not the 14 photos.
Enterprise screen:
Bank:
Ajax code:
$('.requerAjax').click(function(e) {
e.preventDefault();
var resultado = $(this).attr('rel').split('/');
var mes = resultado[0];
var ano = resultado[1];
var categorias_id = resultado[2];
$.ajax({
type: "POST",
url: "/admin/empreendimento/fotos-ajax",
data: { mes: mes, ano: ano, categorias_id: categorias_id },
datatype: 'json',
beforeSend: function(){
$(".carregando").show();
},
success: function(result){
$(".carregando").hide();
var html = "";
for (var i = 0; i < result.length; i++) {
html += "<img src=" + result[i].imagem + " alt=''>";
}
$( ".modal-body .gallery" ).html(html);
}
});
});
Controller code received from ajax:
public function postFotosAjax() {
// $mesAno = Input::all();
$mes = Input::get('mes');
$ano = Input::get('ano');
$id = Input::get('categorias_id');
if(Request::ajax()){
$FotosMesAno = DB::table('fotos')
->select('mes', 'ano', 'imagem')
->where('mes', '=', $mes) // Tem que ser um MES.
->where('ano', '=', $ano, 'AND') // Tem que ser um ANO.
->where('categorias_id', '=', $id, 'AND') // Tem que ser um ID DO EMPREENDIMENTO.
->get();
return Response::json($FotosMesAno);
}
}
I explore how each screen looks:
Enterprise 1
- December / 2014 (Photos registered 8)
- January / 2015 (Photos registered 6)
- February / 2015 (Photos 12)
- March / 2015 (Photos registered 10)
- April / 2015 (Photos registered 8)
Enterprise 2
- December / 2014 (Photos 20)
- January / 2015 (Photos 18)
- February / 2015 (Photos registered 10)
- March / 2015 (Photos 19)
Can someone help me, pull the pictures of each month / year?