1. Go to this page and download the library: Download frictionlessdigital/actions library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Fls\Actions\Action;
class UserAction extends Action
{
public function rules()
{
return [
'name' => ['ction handle($attributes) {
return $this->fill($attributes)->validated();
}
}
UserAction::run([
'name' => 'John',
'email' => '[email protected]',
]);
// ['name' => 'John', 'email' => '[email protected]']
use Fls\Actions\Action;
class UserAction extends Action
{
...
public function handle(User $user, $attributes) {
return $this->fill($attributes)
->validate()
->tap($user, fn(User $user) => $user->update($this->validated()));
}
}
use Fls\Actions\Action;
use App\User;
class CreateUserAction extends Action
{
public function handle(User $user, $attributes)
{
return $user->create($attributes);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.