本文整理汇总了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');
}
}
示例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.
}
示例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>');
}
示例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);
}
}
示例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!');
}
示例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');
}
示例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>');*/
}
示例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>');
}
示例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);
}
示例10: index
public function index()
{
$article = Article::first();
require dirname(__FILE__) . '/../views/test.php';
}
示例11: home
public function home()
{
$this->view = View::make('home')->with('article', Article::first())->withTitle('MFFC :-D');
}