prjkt / reqfuck
Fucking with the FormRequest validation
dev-master
2016-07-19 04:47 UTC
Requires
- php: >=7.0.0
- illuminate/http: 5.1.*|5.2.*|5.3.*
Requires (Dev)
- phpunit/phpunit: ~5.4
This package is not auto-updated.
Last update: 2025-01-10 23:10:00 UTC
README
Fucking with the FormRequest
class for the App\Http\Requests\Request
abstract class.
Requirements
- PHP > 7
- Laravel HTTP > 5.1
Installing
{ "require": { "prjkt/repofuck": "dev-master" } }
** I'll have to ask for forgiveness for installing from dev-master
Usage
<?php namespace App\Http\Requests; class SampleRequest extends Request { protected $rules = [ 'post' => [ 'username' => 'required', 'password' => 'required' ], 'put' => [ 'id' => 'required|exists:users', 'username' => 'required', 'password' => 'min:6' ], ]; }
Juicy stuff
Better used with repofuck
w/ repofuck
app/Repositories/UsersRepository
<?php namespace App\Repositories; use Prjkt\Component\Repofuck\Repofuck as Repository; class UsersRepository extends Repository { protected $resources = [ \App\Entities\User::class ]; }
app/Http/Controllers/UsersController
<?php namespace App\Http\Controllers; use App\Http\Requests\SampleRequest; use App\Repositories\UsersRepository; class UsersController extends Controller { protected $users; public function __construct(UsersRepository $users) { $this->users = $users; } public postUser(SampleRequest $request) { // only mass assign variables based on the validation keys present $user = $this->create($request->all(), $request->getKeys()); } }