Ejemplo n.º 1
0
 /**
  * 
  * @return type
  */
 public static function getGalleries()
 {
     $array = array('0' => 'Válassz galériát!');
     foreach (Gallery::all(['id', 'name']) as $gallery) {
         $array[$gallery->id] = $gallery->name;
     }
     return $array;
 }
Ejemplo n.º 2
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     View::share('title', 'Vezérlőpult');
     $this->layout->content = View::make('admin')->with('article', Article::count())->with('event', Event::count())->with('gallery', Gallery::count())->with('page', Page::count());
 }
Ejemplo n.º 3
0
 /**
  * Display the specified resource.
  * GET /site\gallery/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     View::share('title', 'Galériák');
     $this->layout->content = View::make('site.gallery.show')->with('gallery', Gallery::find($id))->with('url', Request::url());
 }
Ejemplo n.º 4
0
 public function postPicture()
 {
     try {
         // Van-e kiválasztott képfájl
         if (!Input::hasFile('images')) {
             return Redirect::back()->withInput()->withErrors('Nincs kiválasztva feltöltendő képfájl!');
         }
         //Galéria lekérdezése azonosító alapján
         $gallery = Gallery::find(Input::get('id'));
         //Teljes méretű képek elérési útvonala
         $path = '/img/gallery/' . $gallery->id;
         //Thumbnail méretű képek elérési útvonala
         $thumbPath = $path . '/thumb';
         //Könyvátrak létrehozása, ha még nem léteztek
         if (!File::exists(public_path() . $path)) {
             File::makeDirectory(public_path() . $path, 0777, true);
         }
         if (!File::exists(public_path() . $thumbPath)) {
             File::makeDirectory(public_path() . $thumbPath, 0777, true);
         }
         //Képek validálása
         foreach (Input::file('images') as $image) {
             //Szabályok
             $rules = array('file' => 'required|mimes:png,gif,jpeg|max:2048');
             $validator = \Validator::make(array('file' => $image), $rules);
             //Validálás
             if ($validator->passes()) {
                 //Kép objektum létrehozása manipuláláshoz.
                 $imageForManipulation = Image::make($image);
                 //Fájlnév létrehozása.
                 $fileName = microtime(true) . '-' . Str::slug(Str::words($gallery->name, 3, '')) . '.' . $image->getClientOriginalExtension();
                 //Kép és thumbnail létrehozása és elmentése
                 $imageForManipulation->save(public_path() . $path . '/' . $fileName)->fit(250)->save(public_path() . $thumbPath . '/' . $fileName);
                 //Galériakép objektum létrehozása
                 $picture = new Picture();
                 $picture->gallery_id = $gallery->id;
                 $picture->thumbnail_path = $thumbPath . '/' . $fileName;
                 $picture->picture_path = $path . '/' . $fileName;
                 $picture->name = $fileName;
                 if ($picture->save()) {
                     $gallery->touch();
                 } else {
                     return Redirect::back()->withErrors('Hiba történt a képfájl mentésekor! ' . $image->getClientOriginalName());
                 }
             } else {
                 return Redirect::back()->withErrors($validator->errors());
             }
         }
         return Redirect::back()->with('message', 'A képfájlok feltöltése sikeres volt!');
     } catch (Exception $e) {
         if (Config::get('app.debug')) {
             return Response::json(['message' => $e->getMessage(), 'status' => false]);
         } else {
             return Response::json(['message' => 'A(z) ' . $id . ' azonosítójú galéria törlése nem sikerült!', 'status' => false]);
         }
     }
 }
Ejemplo n.º 5
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $page = Page::find($id);
     View::share('title', 'Oldal: ' . $page->title);
     $this->layout->content = View::make('admin.page.edit')->with('page', $page)->with('galleries', Gallery::getGalleries())->with('pages', Page::getPages($id));
 }
Ejemplo n.º 6
0
 /**
  * Show the form for editing the specified resource.
  * GET /admin\article/{id}/edit
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     View::share('title', 'Hír módosítása');
     $this->layout->content = View::make('admin.article.edit')->with('article', Article::find($id))->with('galleries', Gallery::getGalleries());
 }
Ejemplo n.º 7
0
 /**
  * Show the form for editing the specified resource.
  * GET /admin\event/{id}/edit
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     View::share('title', 'Oldalak');
     $this->layout->content = View::make('admin.event.edit')->with('event', Event::find($id))->with('galleries', Gallery::getGalleries());
 }