Пример #1
0
 public function create()
 {
     $category = new Category();
     if (Request::isMethod('post')) {
         $rules = array('name' => 'required', 'description' => 'required');
         $validator = Validator::make(Input::all(), $rules);
         if ($validator->fails()) {
             return Redirect::to('admin/category/create/')->withErrors($validator)->withInput();
         } else {
             if (empty(Input::get('seo_url'))) {
                 $seo_url = Helper::seo_url(Input::get('name'));
             } else {
                 $seo_url = Input::get('seo_url');
             }
             // store
             $category->name = Input::get('name');
             $category->description = Input::get('description');
             $category->seo_url = $seo_url;
             $category->save();
             $directory = $seo_url . '/' . $category->id;
             $tmpFilePath = Config::get('constants.IMAGES_ABSOLUTE_URL') . 'categories/' . $directory . '/';
             $file = Input::file('file');
             if ($file) {
                 $tmpFileName = time() . '-' . $file->getClientOriginalName();
                 $file->move($tmpFilePath, $tmpFileName);
                 $category->thumbnail = $directory . '/' . $tmpFileName;
                 $category->save();
             }
             Session::flash('message', 'Successfully created Category');
             return Redirect::to('/admin/category');
         }
     }
     return view('Admin.category.create')->with(['category' => $category])->withInput(Input::all());
 }
Пример #2
0
 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index()
 {
     $article = new Article();
     if (Request::isMethod('post')) {
         $rules = ['title' => 'required', 'intro' => 'required', 'content' => 'required'];
         $validator = Validator::make(Input::all(), $rules);
         if ($validator->fails()) {
             $messages = $validator->messages();
             return Redirect::to('oszdmeg-te-is')->withErrors($messages)->withInput();
         } else {
             $article = new Article();
             $article->title = Input::get('title');
             $article->intro = Input::get('intro');
             $article->content = Input::get('content');
             $article->display_author_name = Input::get('display_author_name') == 'on' ? Input::get('display_author_name') : 1;
             $article->type_id = 2;
             $article->seo_url = Helpers::seo_url($article->title);
             $article->user = Auth::id();
             $article->save();
             Session::flash('message', 'Köszönjük!.Egyik adminisztrátorunk engedélyezni fogja cikkedet a következő 30 percben.');
             return Redirect::to('/');
         }
     }
     return view('share.index')->with('article', $article);
 }
Пример #3
0
 public function sell()
 {
     $categories = Category::lists('name', 'id');
     if (Request::isMethod('post')) {
         $rules = ['name' => 'required', 'description' => 'required', 'category' => 'required', 'file1' => 'required|mimes:jpeg,bmp,png', 'file2' => 'required|mimes:jpeg,bmp,png'];
         $validator = Validator::make(Input::all(), $rules);
         if ($validator->fails()) {
             $messages = $validator->messages();
             return Redirect::to('piac/eladok')->withErrors($messages)->withInput();
         } else {
             $adv = new Advertisement();
             $adv->name = Input::get('name');
             $adv->description = Input::get('description');
             $adv->category_id = Input::get('category');
             $adv->visible_from = Input::get('visible_from');
             $adv->visible_until = Input::get('visible_until');
             $adv->user_id = Auth::id();
             $adv->seo_url = Helper::lake_directory(Input::get('name'));
             $adv->save();
             if (Input::hasFile('file1') && Input::hasFile('file2')) {
                 $files = [];
                 $files[] = Input::file('file1');
                 $files[] = Input::file('file2');
                 $files[] = Input::file('file3');
                 $files[] = Input::file('file4');
                 $files[] = Input::file('file5');
                 foreach ($files as $key => $file) {
                     $directory = 'USER_' . Auth::id() . '/' . $adv->id;
                     $tmpFilePath = $_SERVER['DOCUMENT_ROOT'] . '/images/advertisements/' . $directory . '/';
                     if ($file) {
                         $tmpFileName = time() . '-' . $file->getClientOriginalName();
                         $file->move($tmpFilePath, $tmpFileName);
                         $advImg = new AdvertisementImage();
                         $advImg->advertisement_id = $adv->id;
                         $advImg->url = $directory . '/' . $tmpFileName;
                         $advImg->save();
                     }
                 }
             }
             Session::flash('message', 'Köszönjük!.Egyik adminisztrátorunk engedélyezni fogja hírdetésedet a következő 30 percben.');
             return Redirect::to('/');
         }
     }
     return view('market.sell', ['categories' => $categories]);
 }
Пример #4
0
 public function upload()
 {
     if (Input::hasFile('file')) {
         $allFiles = Input::file('file');
         $directory = Helper::lake_directory(Input::get('lakeName'));
         $tmpFilePath = '/lakes/' . $directory;
         if (empty($directory) || strlen($directory) < 5) {
             return response()->json(false, 501);
         }
         if ($allFiles) {
             foreach ($allFiles as $file) {
                 $tmpFileName = time() . '-' . $file->getClientOriginalName();
                 $file = $file->move(Config::get('constants.IMAGES_ABSOLUTE_URL') . '' . $tmpFilePath, $tmpFileName);
                 // $path = $tmpFilePath . $tmpFileName;
             }
             return response()->json('OK', 200);
         } else {
             return response()->json(false, 501);
         }
     } else {
         return response()->json(false, 501);
     }
 }
Пример #5
0
 public function create()
 {
     $fish = new Fish();
     if (Request::isMethod('post')) {
         $rules = array('name_ro' => 'required', 'name_hu' => 'required', 'description' => 'required', 'url' => 'required');
         $validator = Validator::make(Input::all(), $rules);
         // process the login
         if ($validator->fails()) {
             return Redirect::to('admin/fish/create/')->withErrors($validator)->withInput();
         } else {
             if (empty(Input::get('fish_seo_url'))) {
                 $seo_url = Helper::seo_url(Input::get('name_ro'));
             } else {
                 $seo_url = $Input::get('fish_seo_url');
             }
             // store
             $fish->name_ro = Input::get('name_ro');
             $fish->name_hu = Input::get('name_hu');
             $fish->url = Input::get('url');
             $fish->description = Input::get('description');
             $fish->enabled = Input::get('enabled') == 'on' ? 1 : 0;
             $fish->save();
             $directory = Helper::lake_directory(Input::get('name_ro'));
             $path = Config::get('constants.IMAGES_ABSOLUTE_URL') . '/fish/' . $directory . '/';
             $images = [];
             if (file_exists($path)) {
                 //Read iamges from file
                 if ($handle = opendir($path)) {
                     while (false !== ($file = readdir($handle))) {
                         if (strpos(strtolower($file), ".jpg") || strpos(strtolower($file), ".gif") || strpos(strtolower($file), ".png")) {
                             $images[] = $file;
                         }
                     }
                     closedir($handle);
                 }
                 $imageIds = [];
                 $fishID = $fish->id;
                 if (!empty($images)) {
                     foreach ($images as $key => $img) {
                         $fishImg = new FishImage();
                         $fishImg->url = $directory . '/' . $img;
                         $fishImg->enabled = 1;
                         $fishImg->uploaded = date("Y-m-d H:i:s");
                         $fishImg->save();
                     }
                 }
             }
             // redirect
             Session::flash('message', 'New fish has been created successfully');
             return Redirect::to('/admin/fishs');
         }
     }
     return view('admin.fish.create')->with(['fish' => $fish]);
 }
Пример #6
0
 public function create()
 {
     $article = new Article();
     if (Request::isMethod('post')) {
         $rules = array('title' => 'required', 'intro' => 'required', 'content' => 'required', 'type_id' => 'required');
         $validator = Validator::make(Input::all(), $rules);
         // process the login
         if ($validator->fails()) {
             return Redirect::to('admin/post/create/')->withErrors($validator)->withInput();
         } else {
             if (empty(Input::get('seo_url'))) {
                 $seo_url = Helper::seo_url(Input::get('title'));
             } else {
                 $seo_url = $Input::get('seo_url');
             }
             // store
             $article->title = Input::get('title');
             $article->intro = Input::get('intro');
             $article->content = Input::get('content');
             $article->user_id = Auth::id();
             $article->type_id = Input::get('type_id');
             $article->display_author_name = Input::get('display_author_name');
             $article->seo_url = $seo_url;
             $article->viewed = 0;
             $article->status = Input::get('enabled') == 'on' ? 1 : 0;
             $article->save();
             // redirect
             Session::flash('message', 'New post has been created successfully');
             return Redirect::to('/admin/post');
         }
     }
     $types = ArticleTypes::lists('name', 'id');
     return view('admin.post.create')->with(['article' => $article, 'types' => $types]);
 }