Skip to content

Commit bd74cfb

Browse files
Adding Abort Trait
1 parent 8ce3ed6 commit bd74cfb

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/Traits/AbortTrait.php

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php namespace Arcanedev\Support\Traits;
2+
3+
/**
4+
* Trait AbortTrait
5+
*
6+
* @package Arcanedev\Support\Traits
7+
* @author ARCANEDEV <arcanedev.maroc@gmail.com>
8+
*/
9+
trait AbortTrait
10+
{
11+
/* ------------------------------------------------------------------------------------------------
12+
| Main Functions
13+
| ------------------------------------------------------------------------------------------------
14+
*/
15+
/**
16+
* Throw Page not found [404].
17+
*
18+
* @param string $message
19+
* @param array $headers
20+
*/
21+
protected static function pageNotFound($message = 'Page not Found', array $headers = [])
22+
{
23+
abort(404, $message, $headers);
24+
}
25+
26+
/**
27+
* Throw AccessNotAllowed [403].
28+
*
29+
* @param string $message
30+
* @param array $headers
31+
*/
32+
protected static function accessNotAllowed($message = 'Access denied !', array $headers = [])
33+
{
34+
abort(403, $message, $headers);
35+
}
36+
}

0 commit comments

Comments
 (0)