本文整理汇总了PHP中app\Article::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Article::save方法的具体用法?PHP Article::save怎么用?PHP Article::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Article
的用法示例。
在下文中一共展示了Article::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postCreate
/**
* @param Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function postCreate(Request $request)
{
$data = $request->all();
$this->article->fill($data);
$this->article->save();
return redirect()->to('articles/index');
}
示例2: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$validator = Validator::make($request->all(), ['title' => 'required|unique:articles|max:255', 'content' => 'required', 'date_published' => 'required']);
if ($validator->fails()) {
return redirect('articles/create')->withErrors($validator)->withInput();
}
$article = new Article(array('title' => $request->get('title'), 'content' => $request->get('content'), 'date_published' => $request->get('date_published'), 'active' => $request->get('active', 0)));
$article->save();
if ($request->file('image')) {
$article->image = downloadImage($request, $article->id, $request->file('image')->getClientOriginalExtension());
$article->save();
}
return redirect()->route('articleEdit', array($article->id))->with('message', 'Article has been added successful!');
}
示例3: store
public function store(Request $request)
{
$article = new Article();
$article->title = $request->input('title');
$article->save();
return redirect('admin/article');
}
示例4: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$article = new Article();
$image = Input::file('image');
if (!empty($image)) {
if (!$image->isValid()) {
return Redirect::back()->withErrors(array('上传文件失败,请重新发表!'));
}
$clientName = $image->getClientOriginalName();
$tmpName = $image->getFileName();
$realPath = $image->getRealPath();
$extension = $image->getClientOriginalExtension();
$newName = md5(date('ymdhis') . $clientName) . '.' . $extension;
$image->move(Utils::getUploadPath(), $newName);
$article->image = $newName;
}
$article->user_id = $request->input('user_id');
$article->title = $request->input('title');
$article->slug = $request->input('slug');
$article->body = $request->input('body');
if (!$article->save()) {
return Redirect::back()->withErrors(array('文章发表失败,请重新发表!'));
}
return Redirect::to('/articles');
}
示例5: store
public function store(Request $request, Article $article)
{
$article->title = $request->input('title');
$article->body = $request->input('body');
$article->save();
return "Done";
}
示例6: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(Request $request)
{
//
$article = new Article();
$splitter = new ImageSplitter($request->request->get('article_content'));
if ($splitter->is_matched) {
for ($i = 0; $i < $splitter->is_matched; $i++) {
$res = new UploadedRes();
$img = $splitter->getImageContent()[$i];
$res->filename = MyUtil::save_file($img);
$res->mime = $splitter->getMime()[$i];
$res->save();
$arr_id[] = $res->id;
}
$article->content = $splitter->getPlainContent($arr_id);
} else {
$article->content = $request->request->get('article_content');
}
$article->title = $request->request->get('article_title');
$article->category = $request->request->get('article_category');
$article->save();
// return response()->json(array("success" => "1", "new_id" => 1), 200,
// array('Content-Type:text/json;charset=UTF-8'));
return response()->json(array("success" => "1", "new_id" => $article->id), 200, array('Content-Type:text/json;charset=UTF-8'));
}
示例7: update
public function update($id)
{
//set previous week
$previousweek = date('Y-m-j H:i:s', strtotime('-7 days'));
$Feed = Feed::find($id);
echo $Feed->url . '<br>';
$feedFactory = new FeedFactory(['cache.enabled' => false]);
$feeder = $feedFactory->make($Feed->url);
$simplePieInstance = $feeder->getRawFeederObject();
//only add articles and update feed when results are found
if (!empty($simplePieInstance)) {
foreach ($simplePieInstance->get_items() as $item) {
$matchThese = ['feed_id' => $Feed->id, 'url' => $item->get_permalink()];
$results = Article::where($matchThese)->count();
$date = $item->get_date('Y-m-j H:i:s');
if ($results == 0 && !(strtotime($date) < strtotime($previousweek))) {
$article = new Article();
$article->feed_id = $Feed->id;
$article->status = 'unread';
$article->url = $item->get_permalink();
$article->subject = $item->get_title();
$article->content = $item->get_description();
$article->published = $item->get_date('Y-m-j H:i:s');
$article->save();
echo '- ' . $item->get_title() . '<br>';
}
}
//update feed updated_at record
Feed::where('id', $Feed->id)->update(['updated_at' => date('Y-m-j H:i:s')]);
Feed::where('id', $Feed->id)->update(['feed_desc' => $simplePieInstance->get_description()]);
Feed::where('id', $Feed->id)->update(['favicon' => $simplePieInstance->get_image_url()]);
}
}
示例8: store
public function store()
{
$article = new Article();
$article->fill(\Input::only(['title', 'content']));
$article->save();
return redirect('/');
}
示例9: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$article = new Article();
$article->title = Input::get('title');
$article->text = Input::get('text');
$article->save();
}
示例10: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$rules = ['ar_title' => 'required', 'fr_title' => 'required', 'ar_contents' => 'required', 'fr_contents' => 'required', 'articlesimage' => 'required|max:10000|mimes:jpeg,png'];
$validator = Validator::make($request->all(), $rules);
$validator->SetAttributeNames(['ar_title' => trans('author.ar_title'), 'fr_title' => trans('author.fr_title'), 'ar_contents' => trans('author.ar_contents'), 'fr_contents' => trans('author.fr_contents'), 'articlesimage' => trans('author.articlesimage')]);
if ($validator->fails()) {
return redirect()->back()->withInput()->withErrors($validator);
} else {
if ($request->hasFile('articlesimage')) {
$image = $request->file('articlesimage');
if ($image->isValid()) {
$article = new Article();
$ext = $image->getClientOriginalExtension();
$imagename = time() . '.' . $ext;
$article->images = $imagename;
$article->ar_titles = $request->input('ar_title');
$article->short_ar_titles = str_limit($article->ar_titles, 15);
$article->fr_titles = $request->input('fr_title');
$article->short_fr_titles = str_limit($article->fr_titles, 15);
$article->ar_contents = $request->input('ar_contents');
$article->short_ar_contents = str_limit($article->ar_contents, 100);
$article->fr_contents = $request->input('fr_contents');
$article->short_fr_contents = str_limit($article->fr_contents, 100);
$article->stat = $request->input('stat');
$article->save();
session()->flash('success', trans('author.success_add'));
$upload = $image->move(base_path() . '/resources/views/dirassa/asset/images', $imagename);
return redirect()->back();
}
}
}
}
示例11: save
private function save(Article $article, array $inputs)
{
$article->title = $inputs['title'];
$article->description = $inputs['description'];
$article->image = $inputs['image'];
$article->save();
}
示例12: store
public function store(ArticleRequest $request)
{
// Request use
// $input = Request::all();
// check data input :: use ArticleRequest class
// $input = $request->all();
// Article::create($input);
$article = new Article($request->all());
// add image
if ($request->hasFile('image')) {
$image_filename = $request->file('image')->getClientOriginalName();
$image_name = date("Ymd-His-") . $image_filename;
$public_path = 'images/articles/';
$destination = base_path() . $public_path;
$request->file('image')->move($destination, $image_name);
$article->image = $public_path . $image_name;
}
// add migration user_id
/* form 1 */
$article->user_id = Auth::user()->id;
$article->save();
/* form 2 */
// Auth::user()->articles()->save($article);
// add many to many
$tagsId = $request->input('tag_list');
if (!empty($tagsId)) {
$article->tags()->sync($tagsId);
}
return redirect('articles');
}
示例13: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(Request $request)
{
// $rules = array(
//'title' => 'required|min:3|max:128',
//'file' => 'mimes:jpg,gif,png'
//);
$this->validate($request, ['title' => 'required|unique:articles|max:255', 'author' => 'required', 'summary' => 'required', 'body' => 'required']);
$article = new Article();
//$article->picture ="";
$article->title = Input::get('title');
$article->author = Input::get('author');
$article->summary = Input::get('summary');
$article->body = Input::get('body');
$article->user_id = Auth::user()->id;
//$article->file = Input::file('file');
// $ext = $file->guessClientExtension();
// $filename = $file->getClientOriginalName();
// $file->move(public_path().'/data', md5(date('YmdHis').$filename).'.'.$ext);
// $pictrue = md5(date('YmdHis').$filename).'.'.$ext;
if ($article->save()) {
return Redirect::to('admin');
} else {
return Redirect::back()->withInput()->withErrors('保存失败!');
}
}
示例14: index
public function index()
{
$article = new Article();
$article->title = 'feiyi';
$article->content = '哈哈';
$result = $article->save();
var_dump($result);
}
示例15: store
/**
* @param ArticleRequest $request
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function store(ArticleRequest $request)
{
$article = new Article($request->all());
$article->user_id = 1;
$article->save();
// \Auth::user()->articles()->save($article);
return redirect('articles');
}