public function postAdd()
 {
     $title = 'Nuevo artículo';
     if (Auth::user() && (Auth::user()->permitido('administrador') || Auth::user()->permitido('remisionero'))) {
         $input = Input::all();
         //Redondea a dos decimales el costo
         $input['cost'] = round($input['cost'], 2);
         //Redondea a dos decimales el precio
         $input['price'] = round($input['price'], 2);
         $v = Validator::make($input, Article::$rules, Article::$messages);
         if ($v->passes()) {
             $idArticle = 1;
             try {
                 $this->article->create($input);
                 $input['id'] = Article::first()->orderBy('created_at', 'desc')->first()->id;
                 $idArticle = $input['id'];
                 self::logChanges(array_except($input, '_token'));
             } catch (Exception $e) {
                 // $message = $e->getMessage();
                 $message = 'No se ha podido guardar el nuevo artículo, quizá exista otro artículo con ese nombre.';
                 Session::flash('message', $message);
                 return Redirect::to('articles/add')->withInput();
             }
             return Redirect::to('articles/search?filterBy=id&search=' . $idArticle)->with(array('messageOk' => 'Artículo creado con éxito.'));
         }
         return Redirect::to('articles/add')->withInput()->withErrors($v)->with('message');
     }
 }
Example #2
0
 public function home()
 {
     // var_dump(Article::count());
     $data = ['title' => '你是谁??', 'email' => '1@baiducom'];
     $validator = $this->validate($data, ['title' => 'required|numeric|integer|min:3|max:4', 'email' => 'required|email']);
     if (!$validator->success) {
         foreach ($validator->errors as $error) {
             echo $error . '<br>';
         }
     }
     Log::debug('First Debug Info.');
     /*
     // mail sample
     Mail::to('*****@*****.**')->from('*****@*****.**')
                           ->title('Foo Bar')
                           ->content('<h1>Hello~~</h1>')
                           ->send();
     // redis sample
     Redis::set('key','value',3000,'ms');
     echo Redis::get('key');
     */
     // return View
     return View::make('home')->with('article', Article::first())->withTitle('TinyLara :-D')->withFooBar('foo_bar');
     // return String
     return 'Hello TinyLara!';
     // or you can return Nothing.
 }
Example #3
0
 public function home()
 {
     $this->view = View::make('home')->with('article', Article::first())->withTitle('MFFC:-D')->withHome('ok!');
     // ->withName(Redis::get('name'));
     //        $this->mail = Mail::to('*****@*****.**')
     //            ->from('*****@*****.**')
     //            ->title('F**k Me!')
     //            ->content('<h1>Hello~~</h1>');
 }
 public function testDeleteArticleWithExistedId()
 {
     //get ramdom id from artidles
     $article = Article::first();
     if ($article instanceof Article) {
         $response = $this->call('DELETE', '/article/' . ($id = $article->id), $params = array(), $file = array(), $server = array(), null);
         $this->assertResponseStatus(204);
     }
 }
Example #5
0
 public function index()
 {
     $result = Test::first();
     echo "<pre>";
     // var_dump($result);
     $first = Article::find(1);
     var_dump($first->content);
     echo '<h1>this is index</h1>';
     $this->view = View::make('home')->with('article', Article::first())->withTitle('MFFC :-D')->withFuck('Ok!');
 }
 public function home()
 {
     $this->view = View::make('home')->with('article', Article::first())->withTitle('MFFC :-D')->withFuckMe('OK!');
     // $this->mail = Mail::to(['*****@*****.**', '*****@*****.**'])
     //                     ->from('M**********r <*****@*****.**>')
     //                     ->title('F**k Me!')
     //                     ->content('<h1>Hello~~</h1>');
     Redis::set('key', 'value', 3000, 'ms');
     echo Redis::get('key');
 }
Example #7
0
 public function home()
 {
     $article = Article::first();
     $this->view = View::make('home')->with('article', $article)->withTitle('title')->withFuckMe('OK!');
     /*$this->mail = Mail::to(['*****@*****.**'])
     
                 ->from('M**********r <*****@*****.**>')
     
                 ->title('F**k Me!')
     
                 ->content('<h1>Hello~~</h1>');*/
 }
Example #8
0
 public function home()
 {
     /*$url = parse_url($_SERVER['REQUEST_URI']);
     		$method = $_SERVER['REQUEST_METHOD'];
     		echo '<pre>';
     		var_export($method);
     		var_export($url);
     		echo '</pre>';*/
     #echo '<h1>控制器成功</h1>';
     #
     $this->view = View::make("home")->with('article', Article::first())->withTitle('MFFC : -D')->withFuckMe('OK!');
     //发邮件
     $this->mail = Mail::to(['*****@*****.**'])->from('MontherFucker <*****@*****.**>')->title('hello')->content('<h1>HELLO~~~~~</h1>');
 }
 /**
  * Index Page for this controller.
  *
  * Maps to the following URL
  * 		http://example.com/index.php/welcome
  *	- or -
  * 		http://example.com/index.php/welcome/index
  *	- or -
  * Since this controller is set as the default controller in
  * config/routes.php, it's displayed at http://example.com/
  *
  * So any other public methods not prefixed with an underscore will
  * map to /index.php/welcome/<method_name>
  * @see http://codeigniter.com/user_guide/general/urls.html
  */
 public function index()
 {
     $data['article'] = Article::first();
     $this->load->view('home', $data);
 }
Example #10
0
 public function index()
 {
     $article = Article::first();
     require dirname(__FILE__) . '/../views/test.php';
 }
Example #11
0
 public function home()
 {
     $this->view = View::make('home')->with('article', Article::first())->withTitle('MFFC :-D');
 }