本文整理汇总了PHP中Notification::error方法的典型用法代码示例。如果您正苦于以下问题:PHP Notification::error方法的具体用法?PHP Notification::error怎么用?PHP Notification::error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Notification
的用法示例。
在下文中一共展示了Notification::error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testErrorCollectingAndReporting
public function testErrorCollectingAndReporting()
{
$n = new Notification();
$this->assertTrue($n->isOk());
$this->assertEquals("", $n->report());
$n->error("An error!");
$this->assertFalse($n->isOk());
$n->error("Some %s occured at %s!", "FOO", "BAR");
$this->assertFalse($n->isOk());
$n->error("Error: %s at line %d occued because %s!", "SNAFU", 5, "FOOBAR");
$this->assertEquals("An error!" . PHP_EOL . "Some FOO occured at BAR!" . PHP_EOL . "Error: SNAFU at line 5 occued because FOOBAR!", $n->report());
}
示例2: handle
/**
* Handle the file upload. Returns the array on success, or false
* on failure.
*
* @param \Symfony\Component\HttpFoundation\File\UploadedFile $file
* @param String $path where to upload file
* @return array|bool
*/
public function handle(UploadedFile $file, $path = 'uploads')
{
$input = array();
$fileName = Str::slug(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME));
// Detect and transform Croppa pattern to avoid problem with Croppa::delete()
$fileName = preg_replace('#([0-9_]+)x([0-9_]+)#', "\$1-\$2", $fileName);
$input['path'] = $path;
$input['extension'] = '.' . $file->getClientOriginalExtension();
$input['filesize'] = $file->getClientSize();
$input['mimetype'] = $file->getClientMimeType();
$input['filename'] = $fileName . $input['extension'];
$fileTypes = Config::get('file.types');
$input['type'] = $fileTypes[strtolower($file->getClientOriginalExtension())];
$filecounter = 1;
while (file_exists($input['path'] . '/' . $input['filename'])) {
$input['filename'] = $fileName . '_' . $filecounter++ . $input['extension'];
}
try {
$file->move($input['path'], $input['filename']);
list($input['width'], $input['height']) = getimagesize($input['path'] . '/' . $input['filename']);
return $input;
} catch (FileException $e) {
Notification::error($e->getmessage());
return false;
}
}
示例3: store
/**
* Start the creation of a new gocardless payment
* Details get posted into this method and the redirected to gocardless
* @param $userId
* @throws \BB\Exceptions\AuthenticationException
* @throws \BB\Exceptions\FormValidationException
* @throws \BB\Exceptions\NotImplementedException
*/
public function store($userId)
{
User::findWithPermission($userId);
$requestData = \Request::only(['reason', 'amount', 'return_path', 'stripeToken', 'ref']);
$stripeToken = $requestData['stripeToken'];
$amount = $requestData['amount'];
$reason = $requestData['reason'];
$returnPath = $requestData['return_path'];
$ref = $requestData['ref'];
try {
$charge = Stripe_Charge::create(array("amount" => $amount, "currency" => "gbp", "card" => $stripeToken, "description" => $reason));
} catch (\Exception $e) {
\Log::error($e);
if (\Request::wantsJson()) {
return \Response::json(['error' => 'There was an error confirming your payment'], 400);
}
\Notification::error("There was an error confirming your payment");
return \Redirect::to($returnPath);
}
//Replace the amount with the one from the charge, this prevents issues with variable tempering
$amount = $charge->amount / 100;
//Stripe don't provide us with the fee so this should be OK
$fee = $amount * 0.024 + 0.2;
$this->paymentRepository->recordPayment($reason, $userId, 'stripe', $charge->id, $amount, 'paid', $fee, $ref);
if (\Request::wantsJson()) {
return \Response::json(['message' => 'Payment made']);
}
\Notification::success("Payment made");
return \Redirect::to($returnPath);
}
示例4: store
/**
* Start the creation of a new balance payment
* Details get posted into this method
* @param $userId
* @throws \BB\Exceptions\AuthenticationException
* @throws \BB\Exceptions\FormValidationException
* @throws \BB\Exceptions\NotImplementedException
*/
public function store($userId)
{
$user = User::findWithPermission($userId);
$this->bbCredit->setUserId($user->id);
$requestData = \Request::only(['reason', 'amount', 'return_path', 'ref']);
$amount = $requestData['amount'] * 1 / 100;
$reason = $requestData['reason'];
$returnPath = $requestData['return_path'];
$ref = $requestData['ref'];
//Can the users balance go below 0
$minimumBalance = $this->bbCredit->acceptableNegativeBalance($reason);
//What is the users balance
$userBalance = $this->bbCredit->getBalance();
//With this payment will the users balance go to low?
if ($userBalance - $amount < $minimumBalance) {
if (\Request::wantsJson()) {
return \Response::json(['error' => 'You don\'t have the money for this'], 400);
}
\Notification::error("You don't have the money for this");
return \Redirect::to($returnPath);
}
//Everything looks gooc, create the payment
$this->paymentRepository->recordPayment($reason, $userId, 'balance', '', $amount, 'paid', 0, $ref);
//Update the users cached balance
$this->bbCredit->recalculate();
if (\Request::wantsJson()) {
return \Response::json(['message' => 'Payment made']);
}
\Notification::success("Payment made");
return \Redirect::to($returnPath);
}
示例5: activate
/**
* Show the form for editing the specified resource.
*
* @param Email $email
* @param $token
* @return \Illuminate\Http\Response
*/
public function activate(Email $email, $token)
{
if ($email->activate($token, auth()->user())) {
\Notification::success(trans('email::email.activation_success'));
} else {
\Notification::error(trans('email::email.activation_failed'));
}
return redirect($this->redirectPath());
}
示例6: store
/**
* Store a newly created resource in storage.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function store()
{
$input = \Input::only('email', 'password');
$this->loginForm->validate($input);
if (Auth::attempt($input, true)) {
return redirect()->intended('account/' . \Auth::id());
}
\Notification::error("Invalid login details");
return redirect()->back()->withInput();
}
示例7: isSWF
public function isSWF($setNotification = true)
{
$imageFileType = $this->getExtension();
if ($imageFileType != "swf") {
if ($setNotification) {
Notification::error(1, 'Only Flash files are allowed.');
}
return false;
}
return true;
}
示例8: file
public static function file($file)
{
$skinPath = self::dir(true) . $file;
$globalPath = self::dir() . $file;
if (file_exists($skinPath)) {
return include $skinPath;
} elseif (file_exists($globalPath)) {
return include $globalPath;
} else {
Notification::error(1, 'file "' . $file . '" Not found! ', 'Template');
}
}
示例9: destroy
/**
* Remove the specified resource from storage.
*
* @param $roleId
* @param $userId
* @return Response
*/
public function destroy($roleId, $userId)
{
$role = Role::findOrFail($roleId);
//don't let people remove the admin permission if they are a trustee
$user = User::findOrFail($userId);
if ($user->active && $user->director && $role->name == 'admin') {
\Notification::error("You cannot remove a trustee from the admin group");
return \Redirect::back();
}
$role->users()->detach($userId);
return \Redirect::back();
}
示例10: online
public static function online($user_id, $plan_id)
{
$input = ['plan_id' => $plan_id, 'validity' => 1, 'validity_unit' => 'Day', 'count' => 1];
try {
DB::transaction(function () use($input, $user_id) {
$pins = Voucher::generate($input);
return self::now(current($pins), $user_id, 'online');
});
} catch (Illuminate\Database\Eloquent\ModelNotFoundException $e) {
Notification::error($e->getMessage());
}
}
示例11: post_index
public function post_index()
{
//POST LOGIN
$credentials = array('cms' => true, 'username' => Input::get('username'), 'password' => Input::get('password'), 'remember' => false);
//CHECK CREDENTIALS
if (Auth::attempt($credentials)) {
//SUCCESS NOTIFICATION
return Redirect::to_action('cms::dashboard');
} else {
//ERROR NOTIFICATION
Notification::error(LL('cms::alert.login_error', CMSLANG));
//BACK TO LOGIN
return Redirect::to_action('cms::login')->with_input('only', array('username'));
}
}
示例12: postEdit
public function postEdit()
{
if (!Input::has('id')) {
Notification::error('Parameter Missing.');
return Redirect::route(self::HOME);
}
$input = Input::all();
try {
$router = Router::findOrFail($input['id']);
$router->fill($input);
$this->flash($router->save());
return Redirect::route(self::HOME);
} catch (Illuminate\Database\Eloquent\ModelNotFoundException $e) {
App::abort(404);
}
}
示例13: destroy
/**
* Remove cash from the users balance
*
* @param $userId
* @return mixed
* @throws \BB\Exceptions\AuthenticationException
* @throws \BB\Exceptions\InvalidDataException
*/
public function destroy($userId)
{
$user = User::findWithPermission($userId);
$this->bbCredit->setUserId($userId);
$amount = \Request::get('amount');
$returnPath = \Request::get('return_path');
$ref = \Request::get('ref');
$minimumBalance = $this->bbCredit->acceptableNegativeBalance('withdrawal');
if ($user->cash_balance + $minimumBalance * 100 < $amount * 100) {
\Notification::error("Not enough money");
return \Redirect::to($returnPath);
}
$this->paymentRepository->recordPayment('withdrawal', $userId, 'balance', '', $amount, 'paid', 0, $ref);
$this->bbCredit->recalculate();
\Notification::success("Payment recorded");
return \Redirect::to($returnPath);
}
示例14: post_delete
public function post_delete()
{
if (Input::has('user_id')) {
$uid = Input::get('user_id');
$user = CmsUser::find($uid);
//CHECK IF USER EXISTS
if (empty($user)) {
Notification::error(LL('cms::alert.delete_user_error', CMSLANG), 2500);
return Redirect::to_action('cms::user');
} else {
$user->delete();
Notification::success(LL('cms::alert.delete_user_success', CMSLANG, array('user' => $user->username)), 1500);
return Redirect::to_action('cms::user');
}
} else {
Notification::error(LL('cms::alert.delete_user_error', CMSLANG), 1500);
return Redirect::to_action('cms::user');
}
}
示例15: render
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
if ($e instanceof FormValidationException) {
if ($request->wantsJson()) {
return \Response::json($e->getErrors(), 422);
}
\Notification::error("Something wasn't right, please check the form for errors", $e->getErrors());
return redirect()->back()->withInput();
}
if ($e instanceof ValidationException) {
if ($request->wantsJson()) {
return \Response::json($e->getMessage(), 422);
}
\Notification::error($e->getMessage());
return redirect()->back()->withInput();
}
if ($e instanceof NotImplementedException) {
\Notification::error("NotImplementedException: " . $e->getMessage());
\Log::warning($e);
return redirect()->back()->withInput();
}
if ($e instanceof AuthenticationException) {
if ($request->wantsJson()) {
return \Response::json(['error' => $e->getMessage()], 403);
}
$userString = \Auth::guest() ? "A guest" : \Auth::user()->name;
\Log::warning($userString . " tried to access something they weren't supposed to.");
return \Response::view('errors.403', [], 403);
}
if ($e instanceof ModelNotFoundException) {
$e = new HttpException(404, $e->getMessage());
}
if (config('app.debug') && $this->shouldReport($e) && !$request->wantsJson()) {
return $this->renderExceptionWithWhoops($e);
}
if ($request->wantsJson()) {
if ($this->isHttpException($e)) {
return \Response::json(['error' => $e->getMessage()], $e->getStatusCode());
}
}
return parent::render($request, $e);
}