Created
May 23, 2015 18:56
-
-
Save stevebauman/3bb086e1c87b3f1b4ff5 to your computer and use it in GitHub Desktop.
Purify Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Your BaseController | |
use Stevebauman\Purfiy\Purify; | |
class BaseController extends Controller | |
{ | |
protected $purfiy; | |
public function __construct(Purify $purfiy) | |
{ | |
$this->purifier = $purify; | |
} | |
private function clean($input) | |
{ | |
return $this->purifier->clean($input); | |
} | |
} | |
// An example form controller, such as a Products controller | |
use App\Models\Product; | |
class ProductsController extends BaseController | |
{ | |
public function store() | |
{ | |
$product = new Product; | |
$product->name = Input::get('name'); | |
$product->description = $this->clean(Input::get('description')); | |
$product->save(); | |
return redirect()->route('products.index')->with(['message' => 'Successfully created product']); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment