laravel - Update database column on button click -


i'm trying update database column on download button click. seems easy yet when click on button counter in database isn't updated.

i'm not sure optimal , correct way of doing here have far.

  1. one input field user pull image api
  2. when image loaded there showed button download , user can download it

also when user search image save in database searched for. controller function pull image + save in database search string. works perfectly

public function getimage(request $request) {     $url = get_curl_content_tx('http://myapi.com/oem?url='.$request->input('url'));     $items = json_decode($url, true);     $thumb = $items['image'];      $in_save = new image();     $in_save->url = $request->input('url');     $in_save->save();         $lastinsertid = $in_save->id;      return view('getimage',compact('thumb', 'lastinsertid')); } 

this function update on download button click

public function getimagedownload(request $request) {            $downrecord = image::find($request->id);       if(!is_null($downrecord) {         $downrecord->update(['counter'=>'1']);         $downrecord->save();     }         return redirect()->route();   } 

the button in view

{!! form::open() !!}     <a type="button" download="{{ $thumb }}" id="{{ $lastinsertid }}" href="{{ $thumb }}" title="" class="btn btn-primary">download image</a>        {!! form::close() !!} 

and routes

route::get('getimage', 'imagecontroller@getimage'); route::post('getimage', 'imagecontroller@getimage'); route::get('getimagedownload', 'imagecontroller@getimagedownload'); 

when click on download image button image downloaded counter isn't updated

upon discussing in chat find out not calling function getimagedownload in view. modified view code him.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -