jeudi 10 août 2017

can someone help me in laravel to fix when i add image on db i got this D:\youssfi\wamp\tmp\php5571.tmp but i want the original name of image

this is my function store in controller :

public function store(VehiculeRequest $request)
{
    $image = $request->image_VH;

    if($image->isValid()) {
        $chemin = config('images.path');
        $extension = $image->getClientOriginalExtension();
        do {
            $nom = str_random(10) . '.' . $extension;
        } while(file_exists($chemin . '/' . $nom));

        $image->move($chemin, $nom);
    }

    $inputs = array_merge($request->all($image));
    $this->VHRepository->store($inputs);
    return redirect(route('vehicules.index'));
}

and this my class repository:

<?php

    namespace App\Repositories;

    use App\Vehicule;
    use App\Http\Requests\VehiculeRequest;

    class VHRepository
    {

        protected $Vehicule;

        public function __construct(Vehicule $Vehicule)
        {
            $this->Vehicule = $Vehicule;
        }

        public function getPaginate($n)
        {
            return $this->Vehicule->with('user')
            ->orderBy('vehicules.created_at', 'desc')
            ->paginate($n);
        }

        public function store($inputs)
        {
            $this->Vehicule->create($inputs);
        }

        public function destroy($id_vehicules)
        {
            $this->Vehicule->findOrFail($id_vehicules)->delete();
        }

    }



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire