Commit 9fd2f8cc by Pancholin

imagenes para publicar y imagenes en carpertas independientes

parent a13dc6b1
......@@ -31,6 +31,9 @@ class ProductResourceServiceProvider extends ServiceProvider
$this->publishes([
__DIR__.'/views/public' => resource_path('views/vendor/onestartup/product_resource'),
]);
$this->publishes([
__DIR__.'/assets' => public_path('vendor/onestartup/product_resource/assets'),
], 'public');
......
......@@ -44,23 +44,22 @@ class AdminProductController extends Controller
{
$product = new Product($request->all());
\Auth::user()->products()->save($product);
if (isset($request->cover)) {
$file = $request->file('cover');
$nombre = $file->getClientOriginalName();
$nombre_file = str_replace(' ', '_', $nombre);
$ubicacion_donde_guarda ='product_resources/cover/'.$nombre_file;
$ubicacion_donde_guarda ='product_resources/cover/'.$product->id.'/'.$nombre_file;
\Storage::disk('local')->put($ubicacion_donde_guarda, \File::get($file));
$product->cover = $ubicacion_donde_guarda;
$product->save();
}
\Auth::user()->products()->save($product);
return redirect()
->route('admin.product.edit', $product->id)
->route('admin.product_resources.products.edit', $product->id)
->with('message_success', "Producto guardado correctamente, continua agregando las imagenes correspondientes");
}
......@@ -95,7 +94,7 @@ class AdminProductController extends Controller
$file = $request->file('cover');
$nombre = $file->getClientOriginalName();
$nombre_file = str_replace(' ', '_', $nombre);
$ubicacion_donde_guarda ='product_resources/cover/'.$nombre_file;
$ubicacion_donde_guarda ='product_resources/cover/'.$product->id.'/'.$nombre_file;
\Storage::disk('local')->put($ubicacion_donde_guarda, \File::get($file));
$product->cover = $ubicacion_donde_guarda;
}
......
......@@ -30,23 +30,23 @@ class CategoryController extends Controller
* @param Request $request
* @return Response
*/
public function store(RequestCreateCategory $request)
public function store(RequestCategory $request)
{
$category = new Category($request->all());
$category->save();
if (isset($request->portada)) {
$file = $request->file('portada');
$nombre = $file->getClientOriginalName();
$nombre_file = str_replace(' ', '_', $nombre);
$ubicacion_donde_guarda ='product_resources/categories/'.$nombre_file;
$ubicacion_donde_guarda ='product_resources/categories/'.$category->id.'/'.$nombre_file;
\Storage::disk('local')->put($ubicacion_donde_guarda, \File::get($file));
$category->cover = $ubicacion_donde_guarda;
$category->save();
}
$category->save();
return redirect()
->back()
->with('message_success', 'Categoria añadida correctamente');
......@@ -79,7 +79,7 @@ class CategoryController extends Controller
$file = $request->file('portada');
$nombre = $file->getClientOriginalName();
$nombre_file = str_replace(' ', '_', $nombre);
$ubicacion_donde_guarda ='product_resources/categories/'.$nombre_file;
$ubicacion_donde_guarda ='product_resources/categories/'.$category->id.'/'.$nombre_file;
\Storage::disk('local')->put($ubicacion_donde_guarda, \File::get($file));
$category->cover = $ubicacion_donde_guarda;
......
......@@ -27,8 +27,6 @@ class RequestProduct extends FormRequest
'name' => 'required|max:355',
'slug' => 'required|max:455',
'description'=> 'required',
'specifications' => 'required',
'features' => 'required',
'active' => 'required|boolean',
'publication_date' => 'required',
'extra1' => 'max:455',
......
......@@ -88,15 +88,19 @@
<div class="row">
@foreach($product->resources as $img)
<div class="col-md-4 text-center">
@if ($img->type == "application/pdf")
<img src="{{asset('assets/img-administrador/pdf.png')}}" width="75%">
@elseif($img->type == "application/msword" || $img->type == "application/vnd.openxmlformats-officedocument.wordprocessingml.document")
<img src="{{asset('assets/img-administrador/doc.png')}}" width="75%">
@elseif($img->type == "application/vnd.ms-excel" || $img->type == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
<img src="{{asset('assets/img-administrador/xls.png')}}" width="75%">
@elseif($img->type == "application/vnd.ms-powerpoint" || $img->type == "application/vnd.openxmlformats-officedocument.presentationml.presentation")
<img src="{{asset('assets/img-administrador/ppt.png')}}" width="75%">
@endif
<a href="{{$img->path}}" target="_blanck">
@if ($img->type == "application/pdf")
<img src="{{asset('vendor/onestartup/product_resource/assets/images/pdf.png')}}" width="75%">
@elseif($img->type == "application/msword" || $img->type == "application/vnd.openxmlformats-officedocument.wordprocessingml.document")
<img src="{{asset('vendor/onestartup/product_resource/assets/images/doc.png')}}" width="75%">
@elseif($img->type == "application/vnd.ms-excel" || $img->type == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
<img src="{{asset('vendor/onestartup/product_resource/assets/images/xls.png')}}" width="75%">
@elseif($img->type == "application/vnd.ms-powerpoint" || $img->type == "application/vnd.openxmlformats-officedocument.presentationml.presentation")
<img src="{{asset('vendor/onestartup/product_resource/assets/images/ppt.png')}}" width="75%">
@else
<img src="{{asset('vendor/onestartup/product_resource/assets/images/file.png')}}" width="75%">
@endif
</a>
<div style="padding-top: 5px">
<span>{{mb_strimwidth($img->name, 0, 12, "...")}}</span>
{!! Form::open(['route'=> ['admin.product_resources.resources.delete',$img->id],'method'=>'DELETE'])!!}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment