Commit 9fd2f8cc by Pancholin

imagenes para publicar y imagenes en carpertas independientes

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