Saves a comment

@throws Exception
@return \Redirect
540139
public function create()
	{
		$return = Input::get('return');
		if (empty($return))
		{
			return Redirect::to('/');
		}
		try {
			$commentable = Input::get('commentable');
			if (empty($commentable))
			{
				throw new Exception();
			}
			$commentable = Crypt::decrypt($commentable);
			if (strpos($commentable, '.') == false)
			{
				throw new Exception();
			}
			list($commentableType, $commentableId) = explode('.', $commentable);
			if (!class_exists($commentableType))
			{
				throw new Exception();
			}
			$data = array(
				'commentable_type' => $commentableType,
				'commentable_id' => $commentableId,
				'comment' => Input::get('comment'),
				'user_id' => Auth::user()->id,
			);
			$rules = $this->comment->getRules($commentableType);
			$validator = Validator::make($data, $rules);
			if ($validator->fails())
			{
				return Redirect::to($return)->withErrors($validator);
			}
			$this->comment->fill($data);
			$this->comment->save();
			$newCommentId = $this->comment->id;
			return Redirect::to($return.'#C'.$newCommentId);

		} catch (\Exception $e) {

			return Redirect::to($return.'#'.trans('laravel-comments::messages.add_form_anchor'))
				->with('laravel-comments::error', trans('laravel-comments::messages.unexpected_error'));

		}

	}
24332
protected function save(CommentsServiceContract $commentsService, SaveCommentRequestContract $request, int $id = 0): SaveResponseContract
    {
        $data = $request->only($commentsService->getModel()->getFillable());
        $parentId = $request->get('parent_comment_id') ?? 0;

        $item = $commentsService->save($data, $id, $parentId);

        return app()->makeWith(SaveResponseContract::class, [
            'item' => $item,
        ]);
    }
964817
public function save()
    {
        // Email address validation tests are NOT handled here as different workflows may have different rules for auto validation
        $app = App::getInstance();

        // If an update
        if ($this->pk && $this->fields[$this->pk]->getValue()) {
            return parent::save();
        }

        $this->setIp($app['env']['RemoteIP']);
        $this->setUseragent($app['env']['RemoteUA']);
        $this->setReferer($app['env']['Referer']);

        if (!$this->getUser()) {
            // check key
            $key_check = $app['akismet']->keyCheck(
                $app->getOption('akismet_api_key', ''),
                $app->getOption('base_url')
            );

            if ($key_check == false) {
                throw new \FelixOnline\Exceptions\InternalException('Akismet key is invalid');
            }

            // check spam using akismet
            $check = $app['akismet']->check(array(
                'permalink' => $this->getArticle()->getURL(),
                'comment_type' => 'comment',
                'comment_author' => $this->fields['name']->getValue(),
                'comment_content' => $this->getComment(),
                'comment_author_email' => $this->getEmail(),
                'user_ip' => $this->getIp(),
                'user_agent' => $this->getUseragent(),
                'referrer' => $this->getReferer(),
            ));

            // check for akismet errors
            if (!is_null($app['akismet']->getError())) {
                throw new \FelixOnline\Exceptions\InternalException($app['akismet']->getError());
            }

            if ($check == true) { // if comment is spam
                $this->setActive(0);
                $this->setPending(0);
                $this->setSpam(1);
            } else { // Not spam
                $this->setActive(1);
                $this->setPending(1);
                $this->setSpam(0);
            }
        } else {
            $this->setActive(1);
            $this->setPending(0);
            $this->setSpam(0);
        }

        parent::save();

        if (!$this->getSpam()) {
            // Send emails
            if (!$this->getUser()) {
                $log_entry = new \FelixOnline\Core\AkismetLog();
                $log_entry->setCommentId($this)
                    ->setAction('check')
                    ->setIsSpam($check)
                    ->setError($app['akismet']->getError())
                    ->save();

                // If pending comment
                if (!$this->getSpam() && $this->getPending() && $this->getActive()) {
                    $this->emailComment();
                }
            }
        }

        return $this->getId(); // return new comment id
    }
779050
protected function SaveActionIdToComment()
    {
        $sActionId = TTools::GetUUID();
        $this->sqlData['action_id'] = $sActionId;
        $this->AllowEditByAll(true);
        $this->Save();
        $this->AllowEditByAll(false);
    }
1058855
protected function registerComment()
    {
        $this->app->singleton('jlourenco.comments.comment', function ($app) {
            $baseConfig = $app['config']->get('jlourenco.base');
            $config = $app['config']->get('jlourenco.comments');

            $model = array_get($config, 'models.comment');
            $users = array_get($baseConfig, 'models.User');

            if (class_exists($model) && method_exists($model, 'setUsersModel'))
                forward_static_call_array([$model, 'setUsersModel'], [$users]);

            return new CommentRepository($model);
        });
    }
96248
function save()
    {
        $file = $this->_getFilePath();

        $data = $this->data;
        $data = $this->getDataInterchange()->makeForward($data);
        $dataStr = "<?php\n". "return " . var_export($data, true) . ";\n";

        ErrorStack::handleError(E_ALL);
        ##  \\\\\
        ### check for directory tree
        $dirPath = dirname($file);
        if (! file_exists($dirPath) )
            if ( false === mkdir($dirPath, 0777, true) )
                throw new \RuntimeException(sprintf('Cant create store directory on (%s).', $dirPath));

        file_put_contents($file, $dataStr, LOCK_EX);
        ##  /////
        if ($exception = ErrorStack::handleDone())
            throw $exception;

        $this->_setState(self::$STATE_OK);
        return $this;
    }
998826
function save() {
		$fw=Base::instance();
		if ($this->flag) {
			if (!is_dir($dir=$fw->get('TEMP')))
				mkdir($dir,Base::MODE,TRUE);
			$this->count++;
			$fw->write($dir.'/'.
				$fw->hash($fw->get('ROOT').$fw->get('BASE')).'.'.
				$fw->hash($this->file).'-'.$this->count.'.png',
				$this->dump());
		}
		return $this;
	}
1371053
public function update(Request $request, Comment $comment)
    {
        $this->authorize('edit-comment', $comment);

        $this->validate($request, [
            'message' => 'required|string'
        ]);

        $comment->update([
            'comment' => $request->message
        ]);

        return redirect()->to(url()->previous() . '#comment-' . $comment->id);
    }
929289
public function save()
    {
        $response = $this->client->put('/{id}', [$this->data->code], $this->data);

        if (! $response->hasErrors()) {
            $this->event->dispatch('PLAN.UPDATE', new PlansEvent($this->data));
        }

        return $this;
    }
1279462
public function addComment($comment)
    {
        $comment->setPaymentId($this->getPaymentId());
        $comment->save();

        $this->load($this->getPaymentId());

        return $comment;
    }
1249203
public function update(CommentRequest $request, Comment $comment)
    {
        try {
            $attributes = $request->all();

            $comment->update($attributes);
            return $this->response->message(trans('messages.success.updated', ['Module' => trans('news::comment.name')]))
                ->code(204)
                ->status('success')
                ->url(guard_url('news/comment/' . $comment->getRouteKey()))
                ->redirect();
        } catch (Exception $e) {
            return $this->response->message($e->getMessage())
                ->code(400)
                ->status('error')
                ->url(guard_url('news/comment/' . $comment->getRouteKey()))
                ->redirect();
        }

    }
978678
public function save()
    {
        if (! $this->getOrigFieldValue(static::IDFIELD)) {
            throw new Exception("Cannot save an item without ID");
        }

        Observer::dispatch(Observer::EVENT_ITEM_SAVE_BEFORE, array(
            'item' => $this
        ));

        $this->{static::DATEUPDATEFIELD} = DateData::now();
        $update = new Update($this);

        $update->commit();

        $this->_origFields = $this->_fields;

        Observer::dispatch(Observer::EVENT_ITEM_SAVE_AFTER, array(
            'item' => $this
        ));

        return $this;
    }
701079
public function removeAllAction()
    {
        $isPosted = $this->request->getPost('doRemoveAll');
        
        if (!$isPosted) {
            $this->response->redirect($this->request->getPost('redirect'));
        }

        $comments = new \Phpmvc\Comment\CommentsInSession();
        $comments->setDI($this->di);

        $comments->deleteAll();

        $this->response->redirect($this->request->getPost('redirect'));
    }
1085099
public function update(CommentUpdateRequest $request, Comment $comment)
    {
        $this->authorize($comment);
        
        $comment->update($request->only(['content']));
        
        return $this->makeRedirect(true, 'admin.comments.index', sprintf(
            __('msg.update'), $comment->url, route('admin.comments.edit', $comment)
        ));
    }
1015747
public function Save () {
		$rawContent = $this->Dump();
		if ($rawContent === FALSE) 
			throw new \Exception('Configuration data was not possible to dump.');
		$app = self::$app ?: self::$app = & \MvcCore\Application::GetInstance();
		$toolClass = $app->GetToolClass();
		try {
			$toolClass::SingleProcessWrite(
				$this->fullPath, 
				$rawContent, 
				'w',	// Open for writing only; place pointer at the beginning and truncate to zero length. If file doesn't exist, create it.
				10,		// Milliseconds to wait before next lock file existence is checked in `while()` cycle.
				5000,	// Maximum milliseconds time to wait before thrown an exception about not possible write.
				30000	// Maximum milliseconds time to consider lock file as operative or as old after some died process.
			);
		} catch (\Exception $ex) {
			throw $ex;
		}
		return TRUE;
	}
971566
public function updateComment( $comment, $user=null, $time = null , $notified = null )
    {
        if ( $time === null )
        {
            $time = time();
        }

        $beforeUpdating = $this->beforeUpdatingComment( $comment, $notified, $time );
        if ( $beforeUpdating !== true )
        {
            return $beforeUpdating;
        }
        $comment->store();

        $afterUpdating = $this->afterUpdatingComment( $comment, $notified, $time );
        if ( $afterUpdating !== true )
        {
            return $afterUpdating;
        }
        return true;
    }
1035825
public function save() {
		if($this->persistent) {
			$action = $this->{'update'};
			$action->directCall($this->attrsForApi($action));
			
		} else {
			// insert
			$action = $this->{'create'};
			$ret = new Response($action, $action->directCall($this->attrsForApi($action)));
			
			if($ret->isOk()) {
				$this->attrs = array_merge($this->attrs, (array) $ret->getResponse());
				
			} else {
				throw new Exception\ActionFailed($ret, "Action '".$action->name()."' failed: ".$ret->message());
			}
			
			$this->persistent = true;
		}
	}