aboutsummaryrefslogblamecommitdiff
path: root/app/Http/Controllers/GalleryController.php
blob: 3f119975e658ae1baf68f32e9ed2de998088218d (plain) (tree)
1
2
3
4
5
6





                               






                                         


















                                                 
                                         









                                                 














                                                                              











































                                                        
                                

     
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use dd;

use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Validator;

use App\Models\Image;

class GalleryController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        return view('pages.gallery');
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        return view('pages.gallery-add');
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        $validatedData = $request->validate([
            'images' => 'required'
        ]);
        $images = $request->file('images');
        foreach ($images as $image) {
            $save = new Image();
            $save->path = 'imgs/';
            $save->name = time() . '.' . $image->getClientOriginalExtension();

            $image->storeAs($save->path, $save->name);

            $save->save();
        }

        return Redirect::back();
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        return Redirect::back();
    }
}