<?php

namespace App\Http\Controllers;

use App\Http\Requests;
use App\Models\File;
use Illuminate\Http\Request;
use Illuminate\Http\Response as HttpResponse;

class FileController extends Controller
{

    public function show()
    {
       
    }

    public function store(Request $request)
    {
        // verify request inputs
        $file = $request->file('file');

        if($file->isValid())
        {
            $chemin = config('file.path');

            $extension = $file->getClientOriginalExtension();

            do {
                $nom = str_random(10) . '.' . $extension;
            } while(file_exists($chemin . '/' . $nom));

            if($file->move($chemin, $nom)) {
                $f = File::create([
                'chemin' => $chemin ,
                'id_Banque' => 1

            ]);
            }
        }
       
    }

    public function edit($titreId)
    {
        //
    }

    public function update(Request $request, $titreId)
    {
        //
    }

    public function destroy($titreId)
    {
        //
    }
}
