コード例 #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 create()
 {
     $lake = new Lake();
     if (Request::isMethod('post')) {
         $rules = array('name' => 'required', 'description' => 'required', 'address' => 'required', 'phone' => 'required', 'email' => 'required|email', 'website' => 'required', 'tax' => 'required', 'access' => 'required', 'contact_person' => 'required', 'latitude' => 'required|numeric', 'longitude' => 'required|numeric');
         $validator = Validator::make(Input::all(), $rules);
         // process the login
         if ($validator->fails()) {
             return Redirect::to('admin/lake/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
             $lake->name = Input::get('name');
             $lake->description = Input::get('description');
             $lake->tax = Input::get('tax');
             $lake->status = Input::get('status') == 'on' ? 1 : 0;
             $lake->latitude = Input::get('latitude');
             $lake->longitude = Input::get('longitude');
             $lake->address = Input::get('address');
             $lake->phone = Input::get('phone');
             $lake->email = Input::get('email');
             $lake->website = Input::get('website');
             $lake->contact_person = Input::get('contact_person');
             $lake->url = Input::get('url');
             $lake->emphasized = Input::get('emphasized') == 'on' ? 1 : 0;
             $lake->seo_url = $seo_url;
             $lake->access = Input::get('access');
             $lake->updated_at = date("Y-m-d H:i:s");
             $lake->save();
             $directory = Helper::lake_directory(Input::get('name'));
             $path = Config::get('constants.IMAGES_ABSOLUTE_URL') . '/lakes/' . $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 = [];
                 $lakeID = $lake->id;
                 if (!empty($images)) {
                     foreach ($images as $key => $img) {
                         $lakeImg = new LakeImage();
                         $lakeImg->url = $directory . '/' . $img;
                         $lakeImg->enabled = 1;
                         $lakeImg->uploaded = date("Y-m-d H:i:s");
                         $lakeImg->save();
                         $imageIds[] = $lakeImg->id;
                     }
                     if (!empty($imageIds)) {
                         foreach ($imageIds as $key => $id) {
                             $lakeHasImage = new LakeHasImage();
                             $lakeHasImage->lake_id = $lakeID;
                             $lakeHasImage->lake_image_id = $id;
                             $lakeHasImage->enabled = 1;
                             $lakeHasImage->save();
                         }
                     }
                 }
             }
             // redirect
             Session::flash('message', 'Successfully created Lake');
             return Redirect::to('/admin/lakes');
         }
     }
     $counties = County::lists('name', 'id');
     return view('admin.lake.create')->with(['lake' => $lake, 'counties' => $counties]);
 }
コード例 #4
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]);
 }
コード例 #5
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]);
 }