/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { //dd('aaaa'); //$conf = $this->datos->delete(); $datos = Inv_imag::find($id); $datos->delete(); Flash::error("Se ha eliminado de forma exitosa!"); return redirect()->route('imagenes.index'); }
public function ImportarImagenes($request) { $file = $request->file('archivo')->getClientOriginalName(); $path_file = storage_path() . '/app/' . $file; //$path_file = \Storage::disk('local').'/inventario.xls'; //Verificamos si se va a borrar los datos de la tabla de INVENTARIO if ($request->borrar) { \DB::statement('SET FOREIGN_KEY_CHECKS = 0'); // disable foreign key constraints \DB::table('inv_imag')->truncate(); \DB::statement('SET FOREIGN_KEY_CHECKS = 1'); // disable foreign key constraints } //$i = 0; \Excel::load($path_file, function ($reader) { // dd($reader->sheetsSelected()); foreach ($reader->get() as $imag) { $inv = Inventario::where('codpro', $imag->codpro)->first(); Inv_imag::create(['inventario_id' => $inv["id"] ? $inv["id"] : 1, 'codpro' => $imag->codpro, 'urlimagen' => $imag->urlimagen]); //$i++; } }); $i = Inventario::count(); return $i; }