Пример #1
0
 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index()
 {
     //echo storage_path().'\framework\sessions';exit;
     $baits = Bait::lists('id', 'name_ro');
     $fishs = Fish::where('enabled', 1)->orderBy('name_hu')->get();
     $county = County::orderBy('name', 'asc')->get();
     //	print_r($county);exit;
     return view('home')->with(['baits' => $baits, 'fishs' => $fishs, 'county' => $county]);
 }
Пример #2
0
 public function run()
 {
     // clear our database ------------------------------------------
     DB::table('bears')->delete();
     DB::table('fish')->delete();
     DB::table('picnics')->delete();
     DB::table('trees')->delete();
     DB::table('bears_picnics')->delete();
     // seed our bears table -----------------------
     // we'll create three different bears
     // bear 1 is named Lawly. She is extremely dangerous. Especially when hungry.
     $bearLawly = Bear::create(array('name' => 'Lawly', 'type' => 'Grizzly', 'danger_level' => 8));
     // bear 2 is named Cerms. He has a loud growl but is pretty much harmless.
     $bearCerms = Bear::create(array('name' => 'Cerms', 'type' => 'Black', 'danger_level' => 4));
     // bear 3 is named Adobot. He is a polar bear. He drinks vodka.
     $bearAdobot = Bear::create(array('name' => 'Adobot', 'type' => 'Polar', 'danger_level' => 3));
     $this->command->info('The bears are alive!');
     // seed our fish table ------------------------
     // our fish wont have names... because theyre going to be eaten
     // we will use the variables we used to create the bears to get their id
     Fish::create(array('weight' => 5, 'bear_id' => $bearLawly->id));
     Fish::create(array('weight' => 12, 'bear_id' => $bearCerms->id));
     Fish::create(array('weight' => 4, 'bear_id' => $bearAdobot->id));
     $this->command->info('They are eating fish!');
     // seed our trees table ---------------------
     Tree::create(array('type' => 'Redwood', 'age' => 500, 'bear_id' => $bearLawly->id));
     Tree::create(array('type' => 'Oak', 'age' => 400, 'bear_id' => $bearLawly->id));
     $this->command->info('Climb bears! Be free!');
     // seed our picnics table ---------------------
     // we will create one picnic and apply all bears to this one picnic
     $picnicYellowstone = Picnic::create(array('name' => 'Yellowstone', 'taste_level' => 6));
     $picnicGrandCanyon = Picnic::create(array('name' => 'Grand Canyon', 'taste_level' => 5));
     // link our bears to picnics ---------------------
     // for our purposes we'll just add all bears to both picnics for our many to many relationship
     $bearLawly->picnics()->attach($picnicYellowstone->id);
     $bearLawly->picnics()->attach($picnicGrandCanyon->id);
     $bearCerms->picnics()->attach($picnicYellowstone->id);
     $bearCerms->picnics()->attach($picnicGrandCanyon->id);
     $bearAdobot->picnics()->attach($picnicYellowstone->id);
     $bearAdobot->picnics()->attach($picnicGrandCanyon->id);
     $this->command->info('They are terrorizing picnics!');
 }
Пример #3
0
 public function fish($name)
 {
     $fish_seo_url = addslashes(strip_tags($name));
     $details = Fish::with(['images'])->where('fish_seo_url', '=', $fish_seo_url)->get()->toArray();
     return view('search.fishDetails')->with('details', $details);
 }
Пример #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]);
 }