Store it in a data-attribute somewhere and fetch it with Javascript when you need it maybe?
Let me know if I have misunderstood you :)
I need to fetch all images based on current url id :eg:localhost:8000/company/post/id using jquery.
public function upload($id)
{
$post= \App\Post::find($id);
return view('gallery.create',compact('post'));
}
public function postUpload(Request $request,$id)
{
$destinationPath = 'gallery';
$extension = $request->file('file')->getClientOriginalExtension();
$fileName = time() . '.' . $extension;
$upload_success = $request->file('file')->move($destinationPath, $fileName);
$image = new Image;
$image->filename = $fileName ;
$image->post_id = $id;
$image->save();
}
Route:
Route::get('company/post/{id}','PostController@upload');
Route::post('images/post/{id}','PostController@postUpload');
view:
<form action="{{url('image/post')}}/{{$post->id}}" enctype="multipart/form-data">
{{ csrf_field() }}
//.......
</form>
<div id="show">display all images here based on current post id in url</div>
//Note: i have upload form above and display div below on same page
<script type="text/javascript">
$(document).ready( function(){
$('#show').load('url that pull all images based on current upload id');
refresh();
});
function refresh()
{
setTimeout( function() {
$('#show').fadeOut('slow').load('/url that pull all images based on current upload id').fadeIn('slow');
refresh();
}, 2000);
}
</script>
for example :my current upload id in browser is localhost::8000/company/post/id
Based on this Id i need to fetch all images in show div using jquery above.
I think i need to make another method that returns all images based on current Post Id.But how to get current Id(ie:$id in above function). in another method so that i call pull images based on that Id
Please or to participate in this conversation.