Skip to content

Instantly share code, notes, and snippets.

@stevebauman
Created May 23, 2015 18:56
Show Gist options
  • Save stevebauman/3bb086e1c87b3f1b4ff5 to your computer and use it in GitHub Desktop.
Save stevebauman/3bb086e1c87b3f1b4ff5 to your computer and use it in GitHub Desktop.
Purify Example
// 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