public function postAdd() { $data = Input::all(); $validation = Validator::make($data, Poster::getValidationRules()); if ($validation->fails()) { return View::make('message', array('OKs' => [], 'errors' => $validation->errors()->all())); } $image_dir = 'images/'; $image_sml_name = "no_image_sml.jpg"; $image_name = "no_image.jpg"; if (Request::hasFile('image')) { $image = Request::file('image'); $image_name = time() . $image->getBasename(); $image->move($image_dir, $image_name); } $data['image_sml'] = $image_dir . $image_sml_name; $data['image'] = $image_dir . $image_name; $data['author_ip'] = $this->getIP(); $data['author_browser'] = $_SERVER['HTTP_USER_AGENT']; $data['author_country'] = "Ukraine"; Poster::create($data); return View::make('message', array('OKs' => ['Poster created'], 'errors' => [''])); /*$data = Input::all(); $validation = Validator::make($data, Poster::getValidationRules()); if ($validation->fails()) { return View::make('message', array('OKs' => [], 'errors' => $validation->errors()->all())); } $image_sml = "images/no_image_sml.jpg"; $image = "images/no_image.jpg"; if (!empty($_FILES['image']['name'])) { $date = time(); Input::upload('image', 'images', $date.$_FILES['image']['name']); if (preg_match('/[.](JPG)|(jpg)|(jpeg)|(JPEG)|(gif)|(GIF)|(png)|(PNG)$/', $_FILES['image']['name'])) { $filename = $_FILES['image']['name']; $source = $_FILES['image']['tmp_name']; $image = $path_directory . $date . $filename; move_uploaded_file($source, $image); $im = null; if (preg_match('/[.](GIF)|(gif)$/', $filename)) $im = imagecreatefromgif($image); if (preg_match('/[.](PNG)|(png)$/', $filename)) $im = imagecreatefrompng($image); if (preg_match('/[.](JPG)|(jpg)|(jpeg)|(JPEG)$/', $filename)) $im = imagecreatefromjpeg($image); $w = 100; $w_src = imagesx($im); $h_src = imagesy($im); $dest = imagecreatetruecolor($w, $w); if ($w_src > $h_src) imagecopyresampled($dest, $im, 0, 0, round((max($w_src, $h_src) - min($w_src, $h_src)) / 2), 0, $w, $w, min($w_src, $h_src), min($w_src, $h_src)); if ($w_src < $h_src) imagecopyresampled($dest, $im, 0, 0, 0, 0, $w, $w, min($w_src, $h_src), min($w_src, $h_src)); if ($w_src == $h_src) imagecopyresampled($dest, $im, 0, 0, 0, 0, $w, $w, $w_src, $w_src); imagejpeg($dest, $path_directory . $date . ".jpg"); $image_sml = $path_directory . $date . ".jpg"; } else return View::make('message', array('OKs' => [], 'errors' => ["Not correct image file"])); } $data['image_sml'] = $image_sml; $data['image'] = $image; $data['author_ip'] = $this->getIP(); $data['author_browser'] = $_SERVER['HTTP_USER_AGENT']; $data['author_country'] = "Ukraine"; Poster::create($data); return View::make('message', array('OKs' => ['Poster created'], 'errors' => ['']));*/ }
public function run() { $i = 0; for ($i = 0; $i < 200; $i++) { Poster::create(['photo_url' => 'http://7xl6gj.com1.z0.glb.clouddn.com/19.2.jpg', 'info_url' => $i + 1, 'daily_id' => '1']); } // Poster::create([ // 'photo_url' => 'http://7xl6gj.com1.z0.glb.clouddn.com/19.3.jpg', // 'info_url'=> '2', // 'daily_id'=> '1' // ]); // Poster::create([ // 'photo_url' => 'http://7xl6gj.com1.z0.glb.clouddn.com/19.4.jpg', // 'info_url'=> '3', // 'daily_id'=> '1' // ]); // Poster::create([ // 'photo_url' => 'http://7xl6gj.com1.z0.glb.clouddn.com/19.5.jpg', // 'info_url'=> '4', // 'daily_id'=> '1' // ]); // Poster::create([ // 'photo_url' => 'http://7xl6gj.com1.z0.glb.clouddn.com/19.5.jpg', // 'info_url'=> '5', // 'daily_id'=> '1' // ]); // Poster::create([ // 'photo_url' => 'http://7xl6gj.com1.z0.glb.clouddn.com/19.2.jpg', // 'info_url'=> '6',//id 号 // 'daily_id'=> '1' // ]); // Poster::create([ // 'photo_url' => 'http://7xl6gj.com1.z0.glb.clouddn.com/19.3.jpg', // 'info_url'=> '7', // 'daily_id'=> '1' // ]); // Poster::create([ // 'photo_url' => 'http://7xl6gj.com1.z0.glb.clouddn.com/19.4.jpg', // 'info_url'=> '8', // 'daily_id'=> '1' // ]); // Poster::create([ // 'photo_url' => 'http://7xl6gj.com1.z0.glb.clouddn.com/19.5.jpg', // 'info_url'=> '9', // 'daily_id'=> '1' // ]); // Poster::create([ // 'photo_url' => 'http://7xl6gj.com1.z0.glb.clouddn.com/19.5.jpg', // 'info_url'=> '10', // 'daily_id'=> '1' // ]); // Poster::create([ // 'photo_url' => 'http://7xl6gj.com1.z0.glb.clouddn.com/19.2.jpg', // 'info_url'=> '11',//id 号 // 'daily_id'=> '1' // ]); // Poster::create([ // 'photo_url' => 'http://7xl6gj.com1.z0.glb.clouddn.com/19.3.jpg', // 'info_url'=> '12', // 'daily_id'=> '1' // ]); // Poster::create([ // 'photo_url' => 'http://7xl6gj.com1.z0.glb.clouddn.com/19.4.jpg', // 'info_url'=> '13', // 'daily_id'=> '1' // ]); // Poster::create([ // 'photo_url' => 'http://7xl6gj.com1.z0.glb.clouddn.com/19.5.jpg', // 'info_url'=> '14', // 'daily_id'=> '1' // ]); // Poster::create([ // 'photo_url' => 'http://7xl6gj.com1.z0.glb.clouddn.com/19.5.jpg', // 'info_url'=> '15', // 'daily_id'=> '1' // ]); }
public function run() { Poster::create(['image' => 'http://7xk6xh.com1.z0.glb.clouddn.com/home_page.png', 'link' => 'http://www.baidu.com']); Poster::create(['image' => 'http://7xk6xh.com1.z0.glb.clouddn.com/home_page.png', 'link' => 'http://www.baidu.com']); }