本文整理汇总了PHP中app\models\Article类的典型用法代码示例。如果您正苦于以下问题:PHP Article类的具体用法?PHP Article怎么用?PHP Article使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Article类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: make
/**
* Return a fresh instance of the model (called on `create()`).
*
* @return \Illuminate\Database\Eloquent\Model
*/
protected function make()
{
$model = new Article();
$model->publish_date = new Carbon();
$model->save();
return $model;
}
示例2: testValidateCorrect
public function testValidateCorrect()
{
$model = new Article(['name' => 'name', 'text' => 'text', 'created_at' => 'created_at', 'updated_at' => 'updated_at', 'user_id' => null]);
$this->specify('event wrong', function () use($model) {
expect('model should not validate', $model->validate())->true();
});
}
示例3: actionFeed
public function actionFeed()
{
$this->layout = false;
$article = new Article();
$data = $article->getArticle();
return $this->render('feed', $data);
}
示例4: index
/**
* Show the application dashboard to the user.
*
* @return Response
*/
public function index()
{
$article = new Article();
if (Request::isMethod('post')) {
$rules = ['title' => 'required', 'intro' => 'required', 'content' => 'required'];
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
$messages = $validator->messages();
return Redirect::to('oszdmeg-te-is')->withErrors($messages)->withInput();
} else {
$article = new Article();
$article->title = Input::get('title');
$article->intro = Input::get('intro');
$article->content = Input::get('content');
$article->display_author_name = Input::get('display_author_name') == 'on' ? Input::get('display_author_name') : 1;
$article->type_id = 2;
$article->seo_url = Helpers::seo_url($article->title);
$article->user = Auth::id();
$article->save();
Session::flash('message', 'Köszönjük!.Egyik adminisztrátorunk engedélyezni fogja cikkedet a következő 30 percben.');
return Redirect::to('/');
}
}
return view('share.index')->with('article', $article);
}
示例5: syncTags
protected function syncTags(Article $article, $tagIds)
{
if (!empty($tagIds)) {
$article->tags()->sync($tagIds);
} else {
$article->tags()->detach();
}
}
示例6: post_mod
public function post_mod()
{
if (Input::exists()) {
$title = Input::get('title');
$mode = (int) Input::get('mode');
$article = new Article();
$article->post_mod($title, $mode);
}
}
示例7: update
/**
* Update the specified resource in storage.
*
* @param Article $article
* @param ArticleRequest $request
* @return \Illuminate\Http\Response
*/
public function update(Article $article, ArticleRequest $request)
{
$article->update($request->all());
if ($tags = $request->get('tag_list')) {
$article->tags()->sync($tags);
}
flash()->success('Article has been edited!');
return Redirect::back();
}
示例8: delete
public function delete(Article $article, $id)
{
$data = $article->find($id);
if (!$data) {
return response()->json(['error' => 'data not found'], 404);
}
$data->delete();
return response()->json(200);
}
示例9: actionDetail
public function actionDetail()
{
$id = Yii::$app->request->get('id');
$article = new Article();
$detail = $article->getDetail($id);
$comment = new Comment();
$comments = $comment->getComments($id);
$visitor = new Visitor();
echo $this->render('detail', ['detail' => $detail, 'comments' => $comments, 'visitor' => $visitor]);
}
示例10: run
/**
* composer require fzaninotto/faker
* Run the database seeds.
*
* @return void
*/
public function run()
{
$faker = Faker\Factory::create();
Article::truncate();
for ($i = 0; $i < 100; $i++) {
$article = new Article();
$article->title = $faker->sentence;
$article->excerpt = $faker->text(200);
$article->content = $faker->text(2000);
$article->author = $faker->name;
$article->category_id = $faker->numberBetween(1, count(Category::count()));
$article->save();
}
}
示例11: seedArticle
protected function seedArticle($name, $technicalName = '', $orderColumnValue = null)
{
$article = new Article();
foreach (config('app.locales') as $locale) {
$article->translate($locale)->name = $name;
$article->translate($locale)->text = '<p class="intro">' . $this->faker->paragraph(6) . '</p>' . '<h3>' . $this->faker->sentence(6) . '</h3>' . '<p>' . $this->faker->paragraph(9) . '</p>' . '<blockquote>' . $this->faker->paragraph(7) . '</blockquote>' . '<h3>' . $this->faker->sentence(6) . '</h3>' . '<p>' . $this->faker->paragraph(10) . '</p>' . '<p>' . $this->faker->paragraph(8) . '</p>';
}
$article->online = true;
$article->technical_name = $technicalName;
$article->draft = false;
$article->order_column = $orderColumnValue;
$article->push();
$this->addImages($article);
}
示例12: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
$data['article'] = Article::find($id);
ArticleStatus::update_view_number($id);
$this->setCommonData();
return view('website.article', $data);
}
示例13: run
public function run()
{
DB::table('user')->delete();
DB::table('pages')->delete();
Article::create(array('title' => 'First post', 'slug' => 'first-post', 'body' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', 'user_id' => 1));
Page::create(array('title' => 'About us', 'slug' => 'about-us', 'body' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', 'user_id' => 1));
}
示例14: index
public function index()
{
$users = User::all()->count();
$trusts = Trusts::groupBy("registry")->get()->count();
$articles = Article::all()->count();
return view('admin/dashboard')->with(['users' => $users, 'trusts' => $trusts, 'articles' => $articles]);
}
示例15: insert
public function insert()
{
/** @var \app\services\GetArticle\ExtractorInterface $extractor */
$extractor = null;
switch ($this->provider) {
case 'verhosvet':
$extractor = new \app\services\GetArticle\Verhosvet($this->url);
break;
case 'youtube':
$extractor = new \app\services\GetArticle\YouTube($this->url);
break;
}
if (is_null($extractor)) {
throw new Exception('Не верный extractor');
}
$row = $extractor->extract();
$articleObject = Article::insert(['header' => $row['header'], 'content' => $row['content'], 'description' => $row['description'], 'source' => $this->url, 'id_string' => Str::rus2translit($row['header']), 'date_insert' => gmdate('YmdHis'), 'tree_node_id_mask' => (new BitMask($this->tree_node_id_mask))->getMask()]);
$this->id = $articleObject->getId();
$image = $row['image'];
$imageContent = file_get_contents($image);
$imageUrl = parse_url($image);
$pathInfo = pathinfo($imageUrl['path']);
$pathInfo['extension'];
$fields = \cs\Widget\FileUpload2\FileUpload::save(File::content($imageContent), $pathInfo['extension'], ['image', 'Картинка', 0, 'string', 'widget' => [FileUpload::className(), ['options' => ['small' => \app\services\GsssHtml::$formatIcon]]]], $this);
$articleObject->update($fields);
return true;
}