當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Article::first方法代碼示例

本文整理匯總了PHP中Article::first方法的典型用法代碼示例。如果您正苦於以下問題:PHP Article::first方法的具體用法?PHP Article::first怎麽用?PHP Article::first使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Article的用法示例。


在下文中一共展示了Article::first方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: postAdd

 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');
     }
 }
開發者ID:heromdn,項目名稱:inventarios,代碼行數:28,代碼來源:ArticleController.php

示例2: home

 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('foo@bar.io')->from('bar@foo.io')
                           ->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.
 }
開發者ID:chenjiantan,項目名稱:TinyLara,代碼行數:27,代碼來源:HomeController.php

示例3: home

 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('943032656@qq.com')
     //            ->from('zwz19940115@163.com')
     //            ->title('Fuck Me!')
     //            ->content('<h1>Hello~~</h1>');
 }
開發者ID:zuofang,項目名稱:foo,代碼行數:9,代碼來源:HomeController.php

示例4: testDeleteArticleWithExistedId

 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);
     }
 }
開發者ID:nguyentienlong,項目名稱:laravel.sandbox,代碼行數:9,代碼來源:ArticleControllerTest.php

示例5: index

 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!');
 }
開發者ID:jceee,項目名稱:MFFC,代碼行數:10,代碼來源:IndexController.php

示例6: home

 public function home()
 {
     $this->view = View::make('home')->with('article', Article::first())->withTitle('MFFC :-D')->withFuckMe('OK!');
     // $this->mail = Mail::to(['ooxx@gmail.com', 'ooxx@qq.com'])
     //                     ->from('MotherFucker <ooxx@163.com>')
     //                     ->title('Fuck Me!')
     //                     ->content('<h1>Hello~~</h1>');
     Redis::set('key', 'value', 3000, 'ms');
     echo Redis::get('key');
 }
開發者ID:xinson,項目名稱:My-First-Framework-based-on-Composer,代碼行數:10,代碼來源:HomeController.php

示例7: home

 public function home()
 {
     $article = Article::first();
     $this->view = View::make('home')->with('article', $article)->withTitle('title')->withFuckMe('OK!');
     /*$this->mail = Mail::to(['xxx@qq.com'])
     
                 ->from('MotherFucker <xxx@163.com>')
     
                 ->title('Fuck Me!')
     
                 ->content('<h1>Hello~~</h1>');*/
 }
開發者ID:fifths,項目名稱:lit,代碼行數:12,代碼來源:HomeController.php

示例8: home

 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(['532974019@qq.com'])->from('MontherFucker <leezhxing@163.com>')->title('hello')->content('<h1>HELLO~~~~~</h1>');
 }
開發者ID:leezhxing,項目名稱:mffc,代碼行數:14,代碼來源:HomeController.php

示例9: index

 /**
  * 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);
 }
開發者ID:NaszvadiG,項目名稱:CodeIgniter-2-with-Eloquent,代碼行數:20,代碼來源:welcome.php

示例10: index

 public function index()
 {
     $article = Article::first();
     require dirname(__FILE__) . '/../views/test.php';
 }
開發者ID:VictorZhn,項目名稱:pyramid,代碼行數:5,代碼來源:TestController.php

示例11: home

 public function home()
 {
     $this->view = View::make('home')->with('article', Article::first())->withTitle('MFFC :-D');
 }
開發者ID:badaozhai,項目名稱:bdzmvc,代碼行數:4,代碼來源:HomeController.php


注:本文中的Article::first方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。