estoy tratando de integrar Image Intervention en mi codigo para poder hacerles un resize a la imagen pero no logro hacerlo funcionar.
El error que arroja es el siguiente:
Argument 1 passed to Illuminate\Database\Eloquent\Builder::make() must be of the type array, object given, called in C:\wamp64\www\proyecto-laravel\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php on line 1570
y el codigo del controllador Image es este:
public function save(Request $request){
//Validacion
$validate = $this->validate($request, [
'description' => 'required',
'image_path' => 'required|mimes:jpeg,png,jpg,gif,svg'
]);
//Recoger datos
$image_path = $request->file('image_path');
$description = $request->input('description');
//Asignar valores al objeto
$user = \Auth::user();
$image = New Image();
$image->user_id = $user->id;
$image->description = $description;
//Subir fichero
if($image_path){
$image_path_name = time().$image_path->getClientOriginalName();
Storage::disk('images')->put($image_path_name, File::get($image_path));
$image->image_path = $image_path_name;
}
//Resize y Subir a la BD
Image::make($image_path)->resize(400,400)->save($image);
//Redirect
return redirect()->route('home')->with([
'message' => 'La imagen se a cargado correctamente'
]);
}
Muchas gracias por responder, te cuento que me sigue dando el mismo error. Te muestro todo el codigo incluido los Facade que estoy utilizando.
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\File;
use App\Image;
use App\Comment;
use App\Like;
use Intervention\Image\ImageManager;
class ImageController extends Controller
{
public function __construct(){
$this->middleware('auth');
}
public function create(){
return view('image.create');
}
public function save(Request $request){
//Validacion
$validate = $this->validate($request, [
'description' => 'required',
'image_path' => 'required|mimes:jpeg,png,jpg,gif,svg'
]);
//Recoger datos
$image_path = $request->file('image_path');
$description = $request->input('description');
//Asignar valores al objeto
$user = \Auth::user();
$image = New Image();
$image->user_id = $user->id;
$image->description = $description;
//Subir fichero
if($image_path){
$image_path_name = time().$image_path->getClientOriginalName();
Storage::disk('images')->put($image_path_name, File::get($image_path));
$image->image_path = $image_path_name;
}
//Resize y Subir a la BD
$image = Image::make($image_path->path())
->resize(400, 400)
->save($image_path_name );
//Redirect
return redirect()->route('home')->with([
'message' => 'La imagen se a cargado correctamente'
]);
}
Si dejo de utilizar el App\Image eso hace que dejen de funcionar ciertas partes de codigo que tengo en el mismo controlador.