vendredi 29 juillet 2016

Extra rows before file download laravel 5.1

Before downloading a file by user I want to log it in the database that user downloaded which file, so I implemented this function below:

  public function downloadTheme(Theme_lang $themLang)
{

    $userOrdered=$this->getUserOrdered();

   if(($themLang->is_free==1) || (in_array($themLang->id,$userOrdered))){
        Theme_download::create(['user_id'=>Auth::user()->id,'theme_lang_id'=>$themLang->id]);
        $file=base_path($themLang->download_url);
        return response()->download($file);
   }else{...}
}

But the problem is when I check the database I see there are extra duplicated rows inserted there! So how can I solve it?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2a5Tg1l
via IFTTT

Aucun commentaire:

Enregistrer un commentaire