SlideShare a Scribd company logo
1 of 67
Wykorzystanie Form Request
przy implementacji API w
Laravelu
Marek Tenus
Full-stack Senior Developer
marek@highsolutions.pl
#1 - Architektura projektu
● NativeScript
● Angular
● TypeScript
● CSS (NativeScript)
● HTML (NativeScript)
#1 - Architektura projektu
● PHP 7.1
● MySQL 5.7
● Laravel 5.5
#1 - Architektura projektu
● PHP 7.1
● MySQL 5.7
● Laravel 5.5
● CSS3
● HTML5
● JavaScript
#2 - Konstrukcja API
DB
#2 - Konstrukcja API
DB
#2 - Konstrukcja API
DB
Client
#2 - Konstrukcja API
DB
Client
Server
#2 - Konstrukcja API
DB
#2 - Konstrukcja API
DB
#2 - Konstrukcja API
#2 - Konstrukcja API
Client
● Send request
● Get response
#2 - Konstrukcja API
Server
● Get request
● Handle request
● Return response
#2 - Konstrukcja API
Auth/Token
request / HTTPS (POST/GET/DELETE/PUT)
#2 - Konstrukcja API
request / HTTPS (POST/GET/DELETE/PUT)
/api/article/1
REST Interface
Auth/Token
#2 - Konstrukcja API
reponse / JSON
#3 - Klasyczna obsługa żądań
Routes
#3 - Klasyczna obsługa żądań
Routes
/api/article GET index
/api/article POST store
#3 - Klasyczna obsługa żądań
Routes Middleware
/api/article GET index
/api/article POST store
#3 - Klasyczna obsługa żądań
Routes Middleware
/api/article GET index
/api/article POST store
allow or deny
#3 - Klasyczna obsługa żądań
Routes Middleware Controller
/api/article GET index
/api/article POST store
allow or deny
#3 - Klasyczna obsługa żądań
Routes Middleware Controller
/api/article GET index
/api/article POST store
allow or deny
get request
handle request
do some stuff
return response
#3 - Klasyczna obsługa żądań
Routes Middleware Controller
/api/article GET index
/api/article POST store
allow or deny
get request
handle request
do some stuff
return response
#3 - Klasyczna obsługa żądań
namespace AppHttpControllersEventController;
use AppHttpControllersController;
use IlluminateHttpRequest;
class EventController extends Controller
{
}
#3 - Klasyczna obsługa żądań
namespace AppHttpControllersEventController;
use AppHttpControllersController;
use IlluminateHttpRequest;
class EventController extends Controller
{
}
#3 - Klasyczna obsługa żądań
public function __construct() {}
public function index() {} //GET
public function create() {} //GET
public function store() {} //POST
public function edit() {} //GET
public function update() {} //PUT/PATCH
public function destroy() {} //DELETE
#3 - Klasyczna obsługa żądań
public function store(Request $request) {
}
#3 - Klasyczna obsługa żądań
public function store(Request $request) {
}
Dependency Injection
#3 - Klasyczna obsługa żądań
public function store() {
$request = request();
}
#3 - Klasyczna obsługa żądań
public function store() {
$request = request();
}
Current instance of Request
#3 - Klasyczna obsługa żądań
public function store(Request $request) {
//authorize the request access(?)
//check if the request has valid data
//store the event member
//give some response
}
#3 - Klasyczna obsługa żądań
//authorize the request access(?)
abort_if(!$request->ajax(), 403);
//check if request has valid data
$request->validate([
'first_name' => 'required|max:191',
'last_name' => 'required|max:191',
'department_id' => 'required|exists:departments,id',
'note' => 'max:512',
]);
//store the event member
EventMember::create($request->all());
//give some response
return [
‘success’ => true,
];
#4 - Form Request
● Klasa dziedzicząca z klasy Request
● Posiada wbudowaną logikę walidacji
● Autoryzacja dostępu do wykonania żądania
● Czy pozwala na więcej?!
#4 - Form Request
Routes Middleware Controller
/api/article GET index
/api/article POST store
allow or deny
get request
handle request
do some stuff
return response
#4 - Form Request
Routes Middleware Controller
/api/article GET index
/api/article POST store
allow or deny
get request
do some stuff
return response
Form
Request
handle request
- validation
- authorization
#4 - Form Request
Routes Middleware Controller
/api/article GET index
/api/article POST store
allow or deny
get request
do some stuff
return response
Form
Request
handle request
- validation
- authorization
#4 - Form Request
php artisan make:request StoreEventMemberRequest
#4 - Form Request
namespace AppHttpRequests;
use IlluminateFoundationHttpFormRequest;
class StoreEventMemberRequest extends FormRequest
{
public function authorize()
{
return false;
}
public function rules()
{
return [
];
}
}
#4 - Form Request
class StoreEventMemberRequest extends FormRequest
{
public function authorize()
{
return true;
}
public function rules()
{
return [
];
}
}
#4 - Form Request
class StoreEventMemberRequest extends FormRequest
{
public function authorize()
{
return true;
}
}
#4 - Form Request
class StoreEventMemberRequest extends FormRequest
{
public function authorize()
{
return $this->ajax();
}
}
true => access
false => 403
#4 - Form Request
class StoreEventMemberRequest extends FormRequest
{
public function authorize()
{
return $this->ajax();
}
} protected function failedAuthorization()
{
throw new HttpResponseException($this->forbiddenResponse());
}
true => access
false => 403
#4 - Form Request
class StoreEventMemberRequest extends FormRequest
{
public function authorize()
{
return true;
}
public function rules()
{
return [
'first_name' => 'required|max:191',
'last_name' => 'required|max:191',
'department_id' => 'required|exists:departments,id',
'note' => 'max:512',
];
}
}
#4 - Form Request
public function messages()
{
return [
‘first_name.required’ => ‘Your first name is required’,
‘last_name.required’ => ‘Your last name is required’,
];
}
#4 - Form Request
public function attributes()
{
return [
‘first_name’ => ‘Your first name’,
‘last_name’ => ‘Your last name’,
];
}
#4 - Form Request
public function withValidator($validator)
{
$validator->after(function ($validator) {
if ($this->somethingElseIsInvalid()) {
$validator->errors()->add('field', 'Something is wrong with this field!');
}
});
}
#4 - Form Request
use AppHttpControllersController;
use IlluminateHttpRequest;
use AppHttpRequestsStoreEventMemberRequest;
class EventController extends Controller
{
}
#4 - Form Request
public function store(StoreEventMemberRequest $request)
{
//authorize the request access(?)
//check if request has valid data
//store the event member
//give some response
}
#4 - Form Request
//authorize the request access(?)
abort_if(!$request->ajax(), 403);
//check if request has valid data
$request->validate([
'first_name' => 'required|max:191',
'last_name' => 'required|max:191',
'department_id' => 'required|exists:departments,id',
'note' => 'max:512',
]);
//store the event member
EventMember::create($request->all());
//give some response
return [
‘success’ => true,
];
#4 - Form Request
//authorize the request access(?)
abort_if(!$request->ajax(), 403);
//check if request has valid data
$request->validate([
'first_name' => 'required|max:191',
'last_name' => 'required|max:191',
'department_id' => 'required|exists:departments,id',
'note' => 'max:512',
]);
//store the event member
EventMember::create($request->all());
//give some response
return [
‘success’ => true,
];
#4 - Form Request
public function store(StoreEventMemberRequest $request) {
EventMember::create($request->all());
return [
‘success’ => true,
];
}
#4 - Form Request
#4 - Form Request
Czy pozwala na
więcej?!
#4 - Form Request
● Oczyszczanie danych formularza (sanitizing)
● Manipulacja danymi formularza (handling)
● Logowanie zdarzeń (logging)
#5 - Zastosowanie Form Request w projekcie
● Oczyszczanie danych formularza (sanitizing)
● Manipulacja danymi formularza (handling)
● Logowanie zdarzeń (logging)
#5 - Zastosowanie Form Request w projekcie
public function all()
{
}
#5 - Zastosowanie Form Request w projekcie
public function all()
{
$attributes = parent::all();
return collect($attributes)
->map(function($field) {
return $field ?? filter_var($field,
FILTER_SANITIZE_STRING);
})
->all();
}
#5 - Zastosowanie Form Request w projekcie
public function all()
{
$attributes = parent::all();
return collect($attributes)
->map(function($field) {
return $field ?? filter_var($field,
FILTER_SANITIZE_STRING);
})
->all();
}
$_POST[‘data’] = [...];
422 (Unprocessable Entity)
#5 - Zastosowanie Form Request w projekcie
public function all()
{
$attributes = parent::all();
return collect($attributes)
->map(function($field) {
return $field ?? filter_var($field,
FILTER_SANITIZE_STRING);
})
->all();
}
$_POST[‘data’] = [...];
422 (Unprocessable Entity)
public function response(array $errors)
{
if ($this->ajax() || $this->wantsJson()) {
return new JsonResponse($errors, 422);
}
return $this->redirector->to($this->getRedirectUrl())
->withInput($this->except($this->dontFlash))
->withErrors($errors, $this->errorBag);
}
#5 - Zastosowanie Form Request w projekcie
public function all()
{
$attributes = parent::all();
return $this->sanitizeAttributes($attributes);
}
$_POST[‘data’] = [...];
protected function sanitizeAttributes($attributes) {
return collect($attributes)
->map(function($field) {
return $field ?? filter_var($field,
FILTER_SANITIZE_STRING);
})
->all();
}
#5 - Zastosowanie Form Request w projekcie
public function all()
{
$attributes = $this->input('data');
$attributes['token'] = $this->input('token');
return $this->sanitizeAttributes($attributes);
}
#5 - Zastosowanie Form Request w projekcie
public function all()
{
return $this->sanitizeAttributes($this->handleAttributes());
}
protected function handleAttributes() {
$attributes = $this->input('data');
$attributes['token'] = $this-
>input('token');
return $attributes;
}
#5 - Zastosowanie Form Request w projekcie
public function all()
{
return $this->sanitizeAttributes($this->handleAttributes());
}
protected function handleAttributes() {
if(!$this->has(‘data’)) {
return parent::all();
}
$attributes = $this->input('data');
$attributes['token'] = $this->input('token');
return $attributes;
}
#6 - Podsumowanie
Zalety
● Clean code
● Dependency Injection
● Security
● Reusability
#6 - Podsumowanie
Wady
● Łamie SRP (Single Responsibility Principle)
● Przesadne używanie Form Request
Marek Tenus
marek@highsolutions.pl

More Related Content

What's hot

WordPress REST API hacking
WordPress REST API hackingWordPress REST API hacking
WordPress REST API hackingJeroen van Dijk
 
Melhorando sua API com DSLs
Melhorando sua API com DSLsMelhorando sua API com DSLs
Melhorando sua API com DSLsAugusto Pascutti
 
The Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/PressThe Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/PressJeroen van Dijk
 
Manipulating Magento - Meet Magento Netherlands 2018
Manipulating Magento - Meet Magento Netherlands 2018Manipulating Magento - Meet Magento Netherlands 2018
Manipulating Magento - Meet Magento Netherlands 2018Joke Puts
 
Drupal Field API. Practical usage
Drupal Field API. Practical usageDrupal Field API. Practical usage
Drupal Field API. Practical usagePavel Makhrinsky
 
Laravel でやってみるクリーンアーキテクチャ #phpconfuk
Laravel でやってみるクリーンアーキテクチャ #phpconfukLaravel でやってみるクリーンアーキテクチャ #phpconfuk
Laravel でやってみるクリーンアーキテクチャ #phpconfukShohei Okada
 
Zend/Expressive 3 – The Next Generation
Zend/Expressive 3 – The Next GenerationZend/Expressive 3 – The Next Generation
Zend/Expressive 3 – The Next GenerationRalf Eggert
 
symfony on action - WebTech 207
symfony on action - WebTech 207symfony on action - WebTech 207
symfony on action - WebTech 207patter
 
Алексей Плеханов: Новинки Laravel 5
Алексей Плеханов: Новинки Laravel 5Алексей Плеханов: Новинки Laravel 5
Алексей Плеханов: Новинки Laravel 5Oleg Poludnenko
 
Get into the FLOW with Extbase
Get into the FLOW with ExtbaseGet into the FLOW with Extbase
Get into the FLOW with ExtbaseJochen Rau
 
Service approach for development REST API in Symfony2
Service approach for development REST API in Symfony2Service approach for development REST API in Symfony2
Service approach for development REST API in Symfony2Sumy PHP User Grpoup
 
Meet Magento Sweden - Magento 2 Layout and Code Compilation for Performance
Meet Magento Sweden - Magento 2 Layout and Code Compilation for PerformanceMeet Magento Sweden - Magento 2 Layout and Code Compilation for Performance
Meet Magento Sweden - Magento 2 Layout and Code Compilation for PerformanceIvan Chepurnyi
 
23.simple login with sessions in laravel 5
23.simple login with sessions in laravel 523.simple login with sessions in laravel 5
23.simple login with sessions in laravel 5Razvan Raducanu, PhD
 
Pim Elshoff "Final Class Aggregate"
Pim Elshoff "Final Class Aggregate"Pim Elshoff "Final Class Aggregate"
Pim Elshoff "Final Class Aggregate"Fwdays
 
Service approach for development Rest API in Symfony2
Service approach for development Rest API in Symfony2Service approach for development Rest API in Symfony2
Service approach for development Rest API in Symfony2Sumy PHP User Grpoup
 

What's hot (20)

Session8
Session8Session8
Session8
 
WordPress REST API hacking
WordPress REST API hackingWordPress REST API hacking
WordPress REST API hacking
 
Melhorando sua API com DSLs
Melhorando sua API com DSLsMelhorando sua API com DSLs
Melhorando sua API com DSLs
 
Lithium Best
Lithium Best Lithium Best
Lithium Best
 
The Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/PressThe Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/Press
 
Manipulating Magento - Meet Magento Netherlands 2018
Manipulating Magento - Meet Magento Netherlands 2018Manipulating Magento - Meet Magento Netherlands 2018
Manipulating Magento - Meet Magento Netherlands 2018
 
Drupal Render API
Drupal Render APIDrupal Render API
Drupal Render API
 
Drupal Field API. Practical usage
Drupal Field API. Practical usageDrupal Field API. Practical usage
Drupal Field API. Practical usage
 
Laravel でやってみるクリーンアーキテクチャ #phpconfuk
Laravel でやってみるクリーンアーキテクチャ #phpconfukLaravel でやってみるクリーンアーキテクチャ #phpconfuk
Laravel でやってみるクリーンアーキテクチャ #phpconfuk
 
Zend/Expressive 3 – The Next Generation
Zend/Expressive 3 – The Next GenerationZend/Expressive 3 – The Next Generation
Zend/Expressive 3 – The Next Generation
 
symfony on action - WebTech 207
symfony on action - WebTech 207symfony on action - WebTech 207
symfony on action - WebTech 207
 
Алексей Плеханов: Новинки Laravel 5
Алексей Плеханов: Новинки Laravel 5Алексей Плеханов: Новинки Laravel 5
Алексей Плеханов: Новинки Laravel 5
 
Get into the FLOW with Extbase
Get into the FLOW with ExtbaseGet into the FLOW with Extbase
Get into the FLOW with Extbase
 
Current state-of-php
Current state-of-phpCurrent state-of-php
Current state-of-php
 
Drupal 8 migrate!
Drupal 8 migrate!Drupal 8 migrate!
Drupal 8 migrate!
 
Service approach for development REST API in Symfony2
Service approach for development REST API in Symfony2Service approach for development REST API in Symfony2
Service approach for development REST API in Symfony2
 
Meet Magento Sweden - Magento 2 Layout and Code Compilation for Performance
Meet Magento Sweden - Magento 2 Layout and Code Compilation for PerformanceMeet Magento Sweden - Magento 2 Layout and Code Compilation for Performance
Meet Magento Sweden - Magento 2 Layout and Code Compilation for Performance
 
23.simple login with sessions in laravel 5
23.simple login with sessions in laravel 523.simple login with sessions in laravel 5
23.simple login with sessions in laravel 5
 
Pim Elshoff "Final Class Aggregate"
Pim Elshoff "Final Class Aggregate"Pim Elshoff "Final Class Aggregate"
Pim Elshoff "Final Class Aggregate"
 
Service approach for development Rest API in Symfony2
Service approach for development Rest API in Symfony2Service approach for development Rest API in Symfony2
Service approach for development Rest API in Symfony2
 

Similar to Laravel Poznań Meetup #2 - Wykorzystanie FormRequest w Laravelu

関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐいHisateru Tanaka
 
Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5Elena Kolevska
 
Application Layer in PHP
Application Layer in PHPApplication Layer in PHP
Application Layer in PHPPer Bernhardt
 
Mashing up JavaScript – Advanced Techniques for modern Web Apps
Mashing up JavaScript – Advanced Techniques for modern Web AppsMashing up JavaScript – Advanced Techniques for modern Web Apps
Mashing up JavaScript – Advanced Techniques for modern Web AppsBastian Hofmann
 
What's New In Laravel 5
What's New In Laravel 5What's New In Laravel 5
What's New In Laravel 5Darren Craig
 
SQLite Techniques
SQLite TechniquesSQLite Techniques
SQLite Techniquesjoaopmaia
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For BeginnersJonathan Wage
 
Introduction to Zend Framework web services
Introduction to Zend Framework web servicesIntroduction to Zend Framework web services
Introduction to Zend Framework web servicesMichelangelo van Dam
 
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram VaswaniCreating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswanivvaswani
 
Laravel 5 In Depth
Laravel 5 In DepthLaravel 5 In Depth
Laravel 5 In DepthKirk Bushell
 
PSR-7, middlewares e o futuro dos frameworks
PSR-7, middlewares e o futuro dos frameworksPSR-7, middlewares e o futuro dos frameworks
PSR-7, middlewares e o futuro dos frameworksElton Minetto
 
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...ZFConf Conference
 
Magento Live Australia 2016: Request Flow
Magento Live Australia 2016: Request FlowMagento Live Australia 2016: Request Flow
Magento Live Australia 2016: Request FlowVrann Tulika
 
Easy rest service using PHP reflection api
Easy rest service using PHP reflection apiEasy rest service using PHP reflection api
Easy rest service using PHP reflection apiMatthieu Aubry
 

Similar to Laravel Poznań Meetup #2 - Wykorzystanie FormRequest w Laravelu (20)

関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい
 
Chekout demistified
Chekout demistifiedChekout demistified
Chekout demistified
 
Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5
 
Application Layer in PHP
Application Layer in PHPApplication Layer in PHP
Application Layer in PHP
 
Mashing up JavaScript
Mashing up JavaScriptMashing up JavaScript
Mashing up JavaScript
 
Mashing up JavaScript – Advanced Techniques for modern Web Apps
Mashing up JavaScript – Advanced Techniques for modern Web AppsMashing up JavaScript – Advanced Techniques for modern Web Apps
Mashing up JavaScript – Advanced Techniques for modern Web Apps
 
22.sessions in laravel
22.sessions in laravel22.sessions in laravel
22.sessions in laravel
 
What's New In Laravel 5
What's New In Laravel 5What's New In Laravel 5
What's New In Laravel 5
 
Zend framework service
Zend framework serviceZend framework service
Zend framework service
 
Zend framework service
Zend framework serviceZend framework service
Zend framework service
 
SQLite Techniques
SQLite TechniquesSQLite Techniques
SQLite Techniques
 
SQLite Techniques
SQLite TechniquesSQLite Techniques
SQLite Techniques
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For Beginners
 
Introduction to Zend Framework web services
Introduction to Zend Framework web servicesIntroduction to Zend Framework web services
Introduction to Zend Framework web services
 
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram VaswaniCreating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
 
Laravel 5 In Depth
Laravel 5 In DepthLaravel 5 In Depth
Laravel 5 In Depth
 
PSR-7, middlewares e o futuro dos frameworks
PSR-7, middlewares e o futuro dos frameworksPSR-7, middlewares e o futuro dos frameworks
PSR-7, middlewares e o futuro dos frameworks
 
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
 
Magento Live Australia 2016: Request Flow
Magento Live Australia 2016: Request FlowMagento Live Australia 2016: Request Flow
Magento Live Australia 2016: Request Flow
 
Easy rest service using PHP reflection api
Easy rest service using PHP reflection apiEasy rest service using PHP reflection api
Easy rest service using PHP reflection api
 

More from HighSolutions Sp. z o.o.

Laravel Poland Meetup #22 - "Kilka slajdów o castowaniu atrybutów w Eloquent"
Laravel Poland Meetup #22 - "Kilka slajdów o castowaniu atrybutów w Eloquent"Laravel Poland Meetup #22 - "Kilka slajdów o castowaniu atrybutów w Eloquent"
Laravel Poland Meetup #22 - "Kilka slajdów o castowaniu atrybutów w Eloquent"HighSolutions Sp. z o.o.
 
Laravel Poznań Meetup #16 - "Action-based Laravel"
Laravel Poznań Meetup #16 - "Action-based Laravel" Laravel Poznań Meetup #16 - "Action-based Laravel"
Laravel Poznań Meetup #16 - "Action-based Laravel" HighSolutions Sp. z o.o.
 
Laravel Poznań Meetup #12 - "Speed up web API with Laravel and Swoole using ...
 Laravel Poznań Meetup #12 - "Speed up web API with Laravel and Swoole using ... Laravel Poznań Meetup #12 - "Speed up web API with Laravel and Swoole using ...
Laravel Poznań Meetup #12 - "Speed up web API with Laravel and Swoole using ...HighSolutions Sp. z o.o.
 
Laravel Poznań Meetup #12 - "Laravel 6.0 - co nowego?"
Laravel Poznań Meetup #12 - "Laravel 6.0 - co nowego?"Laravel Poznań Meetup #12 - "Laravel 6.0 - co nowego?"
Laravel Poznań Meetup #12 - "Laravel 6.0 - co nowego?"HighSolutions Sp. z o.o.
 
Dni Kariery - "Turkusowe organizacje. Nowoczesny styl zarządzania"
Dni Kariery - "Turkusowe organizacje. Nowoczesny styl zarządzania"Dni Kariery - "Turkusowe organizacje. Nowoczesny styl zarządzania"
Dni Kariery - "Turkusowe organizacje. Nowoczesny styl zarządzania"HighSolutions Sp. z o.o.
 
Laravel Poznań Meetup #8 - "Laravel czy lumen, oto jest pytanie"
Laravel Poznań Meetup #8 - "Laravel czy lumen, oto jest pytanie"Laravel Poznań Meetup #8 - "Laravel czy lumen, oto jest pytanie"
Laravel Poznań Meetup #8 - "Laravel czy lumen, oto jest pytanie"HighSolutions Sp. z o.o.
 
Laravel Poznań Meetup #8 - "Laravel Telescope - niezastąpione narzędzie do de...
Laravel Poznań Meetup #8 - "Laravel Telescope - niezastąpione narzędzie do de...Laravel Poznań Meetup #8 - "Laravel Telescope - niezastąpione narzędzie do de...
Laravel Poznań Meetup #8 - "Laravel Telescope - niezastąpione narzędzie do de...HighSolutions Sp. z o.o.
 
Laravel Poznań Meetup #7 - "Praktyczne użycie Repository Pattern w Laravel cz...
Laravel Poznań Meetup #7 - "Praktyczne użycie Repository Pattern w Laravel cz...Laravel Poznań Meetup #7 - "Praktyczne użycie Repository Pattern w Laravel cz...
Laravel Poznań Meetup #7 - "Praktyczne użycie Repository Pattern w Laravel cz...HighSolutions Sp. z o.o.
 
Laravel Poznań Meetup #7 - "PWA - Progressive Web App"
Laravel Poznań Meetup #7 - "PWA - Progressive Web App"Laravel Poznań Meetup #7 - "PWA - Progressive Web App"
Laravel Poznań Meetup #7 - "PWA - Progressive Web App"HighSolutions Sp. z o.o.
 
Laravel Poznań Meetup #7 - "Laravel nova - czy to się w ogóle opłaca"
Laravel Poznań Meetup #7 - "Laravel nova - czy to się w ogóle opłaca"Laravel Poznań Meetup #7 - "Laravel nova - czy to się w ogóle opłaca"
Laravel Poznań Meetup #7 - "Laravel nova - czy to się w ogóle opłaca"HighSolutions Sp. z o.o.
 
Laravel Poznań Meetup #6 - "Nowości w Laravel 5.7"
Laravel Poznań Meetup #6 - "Nowości w Laravel 5.7"Laravel Poznań Meetup #6 - "Nowości w Laravel 5.7"
Laravel Poznań Meetup #6 - "Nowości w Laravel 5.7"HighSolutions Sp. z o.o.
 
Laravel Poznań Meetup #4 - EloquentSequence - Historia pewnej biblioteki Open...
Laravel Poznań Meetup #4 - EloquentSequence - Historia pewnej biblioteki Open...Laravel Poznań Meetup #4 - EloquentSequence - Historia pewnej biblioteki Open...
Laravel Poznań Meetup #4 - EloquentSequence - Historia pewnej biblioteki Open...HighSolutions Sp. z o.o.
 
Laravel Poznań Meetup #3 - Uruchomienie i praca z Laravel w wirtualnym konten...
Laravel Poznań Meetup #3 - Uruchomienie i praca z Laravel w wirtualnym konten...Laravel Poznań Meetup #3 - Uruchomienie i praca z Laravel w wirtualnym konten...
Laravel Poznań Meetup #3 - Uruchomienie i praca z Laravel w wirtualnym konten...HighSolutions Sp. z o.o.
 
How business and IT should cooperate with each other to verify business model...
How business and IT should cooperate with each other to verify business model...How business and IT should cooperate with each other to verify business model...
How business and IT should cooperate with each other to verify business model...HighSolutions Sp. z o.o.
 
Jak Biznes i IT powinny współpracować ze sobą by zweryfikować model biznesowy...
Jak Biznes i IT powinny współpracować ze sobą by zweryfikować model biznesowy...Jak Biznes i IT powinny współpracować ze sobą by zweryfikować model biznesowy...
Jak Biznes i IT powinny współpracować ze sobą by zweryfikować model biznesowy...HighSolutions Sp. z o.o.
 
Laravel Poznań Meetup #2 - Creating chatbots with BotMan
Laravel Poznań Meetup #2 - Creating chatbots with BotManLaravel Poznań Meetup #2 - Creating chatbots with BotMan
Laravel Poznań Meetup #2 - Creating chatbots with BotManHighSolutions Sp. z o.o.
 
Laravel Poznań Meetup #2 - Koniec CSS? Jest Tailwind!
Laravel Poznań Meetup #2 - Koniec CSS? Jest Tailwind!Laravel Poznań Meetup #2 - Koniec CSS? Jest Tailwind!
Laravel Poznań Meetup #2 - Koniec CSS? Jest Tailwind!HighSolutions Sp. z o.o.
 
Laravel Poznań Meetup #2 - Tworzenie chatbotów z BotMan
Laravel Poznań Meetup #2 - Tworzenie chatbotów z BotManLaravel Poznań Meetup #2 - Tworzenie chatbotów z BotMan
Laravel Poznań Meetup #2 - Tworzenie chatbotów z BotManHighSolutions Sp. z o.o.
 
Jak błędów unikać prowadząc własną firmę i jak ją rozwijać
Jak błędów unikać prowadząc własną firmę i jak ją rozwijaćJak błędów unikać prowadząc własną firmę i jak ją rozwijać
Jak błędów unikać prowadząc własną firmę i jak ją rozwijaćHighSolutions Sp. z o.o.
 

More from HighSolutions Sp. z o.o. (19)

Laravel Poland Meetup #22 - "Kilka slajdów o castowaniu atrybutów w Eloquent"
Laravel Poland Meetup #22 - "Kilka slajdów o castowaniu atrybutów w Eloquent"Laravel Poland Meetup #22 - "Kilka slajdów o castowaniu atrybutów w Eloquent"
Laravel Poland Meetup #22 - "Kilka slajdów o castowaniu atrybutów w Eloquent"
 
Laravel Poznań Meetup #16 - "Action-based Laravel"
Laravel Poznań Meetup #16 - "Action-based Laravel" Laravel Poznań Meetup #16 - "Action-based Laravel"
Laravel Poznań Meetup #16 - "Action-based Laravel"
 
Laravel Poznań Meetup #12 - "Speed up web API with Laravel and Swoole using ...
 Laravel Poznań Meetup #12 - "Speed up web API with Laravel and Swoole using ... Laravel Poznań Meetup #12 - "Speed up web API with Laravel and Swoole using ...
Laravel Poznań Meetup #12 - "Speed up web API with Laravel and Swoole using ...
 
Laravel Poznań Meetup #12 - "Laravel 6.0 - co nowego?"
Laravel Poznań Meetup #12 - "Laravel 6.0 - co nowego?"Laravel Poznań Meetup #12 - "Laravel 6.0 - co nowego?"
Laravel Poznań Meetup #12 - "Laravel 6.0 - co nowego?"
 
Dni Kariery - "Turkusowe organizacje. Nowoczesny styl zarządzania"
Dni Kariery - "Turkusowe organizacje. Nowoczesny styl zarządzania"Dni Kariery - "Turkusowe organizacje. Nowoczesny styl zarządzania"
Dni Kariery - "Turkusowe organizacje. Nowoczesny styl zarządzania"
 
Laravel Poznań Meetup #8 - "Laravel czy lumen, oto jest pytanie"
Laravel Poznań Meetup #8 - "Laravel czy lumen, oto jest pytanie"Laravel Poznań Meetup #8 - "Laravel czy lumen, oto jest pytanie"
Laravel Poznań Meetup #8 - "Laravel czy lumen, oto jest pytanie"
 
Laravel Poznań Meetup #8 - "Laravel Telescope - niezastąpione narzędzie do de...
Laravel Poznań Meetup #8 - "Laravel Telescope - niezastąpione narzędzie do de...Laravel Poznań Meetup #8 - "Laravel Telescope - niezastąpione narzędzie do de...
Laravel Poznań Meetup #8 - "Laravel Telescope - niezastąpione narzędzie do de...
 
Laravel Poznań Meetup #7 - "Praktyczne użycie Repository Pattern w Laravel cz...
Laravel Poznań Meetup #7 - "Praktyczne użycie Repository Pattern w Laravel cz...Laravel Poznań Meetup #7 - "Praktyczne użycie Repository Pattern w Laravel cz...
Laravel Poznań Meetup #7 - "Praktyczne użycie Repository Pattern w Laravel cz...
 
Laravel Poznań Meetup #7 - "PWA - Progressive Web App"
Laravel Poznań Meetup #7 - "PWA - Progressive Web App"Laravel Poznań Meetup #7 - "PWA - Progressive Web App"
Laravel Poznań Meetup #7 - "PWA - Progressive Web App"
 
Laravel Poznań Meetup #7 - "Laravel nova - czy to się w ogóle opłaca"
Laravel Poznań Meetup #7 - "Laravel nova - czy to się w ogóle opłaca"Laravel Poznań Meetup #7 - "Laravel nova - czy to się w ogóle opłaca"
Laravel Poznań Meetup #7 - "Laravel nova - czy to się w ogóle opłaca"
 
Laravel Poznań Meetup #6 - "Nowości w Laravel 5.7"
Laravel Poznań Meetup #6 - "Nowości w Laravel 5.7"Laravel Poznań Meetup #6 - "Nowości w Laravel 5.7"
Laravel Poznań Meetup #6 - "Nowości w Laravel 5.7"
 
Laravel Poznań Meetup #4 - EloquentSequence - Historia pewnej biblioteki Open...
Laravel Poznań Meetup #4 - EloquentSequence - Historia pewnej biblioteki Open...Laravel Poznań Meetup #4 - EloquentSequence - Historia pewnej biblioteki Open...
Laravel Poznań Meetup #4 - EloquentSequence - Historia pewnej biblioteki Open...
 
Laravel Poznań Meetup #3 - Uruchomienie i praca z Laravel w wirtualnym konten...
Laravel Poznań Meetup #3 - Uruchomienie i praca z Laravel w wirtualnym konten...Laravel Poznań Meetup #3 - Uruchomienie i praca z Laravel w wirtualnym konten...
Laravel Poznań Meetup #3 - Uruchomienie i praca z Laravel w wirtualnym konten...
 
How business and IT should cooperate with each other to verify business model...
How business and IT should cooperate with each other to verify business model...How business and IT should cooperate with each other to verify business model...
How business and IT should cooperate with each other to verify business model...
 
Jak Biznes i IT powinny współpracować ze sobą by zweryfikować model biznesowy...
Jak Biznes i IT powinny współpracować ze sobą by zweryfikować model biznesowy...Jak Biznes i IT powinny współpracować ze sobą by zweryfikować model biznesowy...
Jak Biznes i IT powinny współpracować ze sobą by zweryfikować model biznesowy...
 
Laravel Poznań Meetup #2 - Creating chatbots with BotMan
Laravel Poznań Meetup #2 - Creating chatbots with BotManLaravel Poznań Meetup #2 - Creating chatbots with BotMan
Laravel Poznań Meetup #2 - Creating chatbots with BotMan
 
Laravel Poznań Meetup #2 - Koniec CSS? Jest Tailwind!
Laravel Poznań Meetup #2 - Koniec CSS? Jest Tailwind!Laravel Poznań Meetup #2 - Koniec CSS? Jest Tailwind!
Laravel Poznań Meetup #2 - Koniec CSS? Jest Tailwind!
 
Laravel Poznań Meetup #2 - Tworzenie chatbotów z BotMan
Laravel Poznań Meetup #2 - Tworzenie chatbotów z BotManLaravel Poznań Meetup #2 - Tworzenie chatbotów z BotMan
Laravel Poznań Meetup #2 - Tworzenie chatbotów z BotMan
 
Jak błędów unikać prowadząc własną firmę i jak ją rozwijać
Jak błędów unikać prowadząc własną firmę i jak ją rozwijaćJak błędów unikać prowadząc własną firmę i jak ją rozwijać
Jak błędów unikać prowadząc własną firmę i jak ją rozwijać
 

Recently uploaded

Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 

Recently uploaded (20)

Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 

Laravel Poznań Meetup #2 - Wykorzystanie FormRequest w Laravelu

  • 1. Wykorzystanie Form Request przy implementacji API w Laravelu
  • 2. Marek Tenus Full-stack Senior Developer marek@highsolutions.pl
  • 3. #1 - Architektura projektu ● NativeScript ● Angular ● TypeScript ● CSS (NativeScript) ● HTML (NativeScript)
  • 4. #1 - Architektura projektu ● PHP 7.1 ● MySQL 5.7 ● Laravel 5.5
  • 5. #1 - Architektura projektu ● PHP 7.1 ● MySQL 5.7 ● Laravel 5.5 ● CSS3 ● HTML5 ● JavaScript
  • 8. #2 - Konstrukcja API DB Client
  • 9. #2 - Konstrukcja API DB Client Server
  • 13. #2 - Konstrukcja API Client ● Send request ● Get response
  • 14. #2 - Konstrukcja API Server ● Get request ● Handle request ● Return response
  • 15. #2 - Konstrukcja API Auth/Token request / HTTPS (POST/GET/DELETE/PUT)
  • 16. #2 - Konstrukcja API request / HTTPS (POST/GET/DELETE/PUT) /api/article/1 REST Interface Auth/Token
  • 17. #2 - Konstrukcja API reponse / JSON
  • 18. #3 - Klasyczna obsługa żądań Routes
  • 19. #3 - Klasyczna obsługa żądań Routes /api/article GET index /api/article POST store
  • 20. #3 - Klasyczna obsługa żądań Routes Middleware /api/article GET index /api/article POST store
  • 21. #3 - Klasyczna obsługa żądań Routes Middleware /api/article GET index /api/article POST store allow or deny
  • 22. #3 - Klasyczna obsługa żądań Routes Middleware Controller /api/article GET index /api/article POST store allow or deny
  • 23. #3 - Klasyczna obsługa żądań Routes Middleware Controller /api/article GET index /api/article POST store allow or deny get request handle request do some stuff return response
  • 24. #3 - Klasyczna obsługa żądań Routes Middleware Controller /api/article GET index /api/article POST store allow or deny get request handle request do some stuff return response
  • 25. #3 - Klasyczna obsługa żądań namespace AppHttpControllersEventController; use AppHttpControllersController; use IlluminateHttpRequest; class EventController extends Controller { }
  • 26. #3 - Klasyczna obsługa żądań namespace AppHttpControllersEventController; use AppHttpControllersController; use IlluminateHttpRequest; class EventController extends Controller { }
  • 27. #3 - Klasyczna obsługa żądań public function __construct() {} public function index() {} //GET public function create() {} //GET public function store() {} //POST public function edit() {} //GET public function update() {} //PUT/PATCH public function destroy() {} //DELETE
  • 28. #3 - Klasyczna obsługa żądań public function store(Request $request) { }
  • 29. #3 - Klasyczna obsługa żądań public function store(Request $request) { } Dependency Injection
  • 30. #3 - Klasyczna obsługa żądań public function store() { $request = request(); }
  • 31. #3 - Klasyczna obsługa żądań public function store() { $request = request(); } Current instance of Request
  • 32. #3 - Klasyczna obsługa żądań public function store(Request $request) { //authorize the request access(?) //check if the request has valid data //store the event member //give some response }
  • 33. #3 - Klasyczna obsługa żądań //authorize the request access(?) abort_if(!$request->ajax(), 403); //check if request has valid data $request->validate([ 'first_name' => 'required|max:191', 'last_name' => 'required|max:191', 'department_id' => 'required|exists:departments,id', 'note' => 'max:512', ]); //store the event member EventMember::create($request->all()); //give some response return [ ‘success’ => true, ];
  • 34. #4 - Form Request ● Klasa dziedzicząca z klasy Request ● Posiada wbudowaną logikę walidacji ● Autoryzacja dostępu do wykonania żądania ● Czy pozwala na więcej?!
  • 35. #4 - Form Request Routes Middleware Controller /api/article GET index /api/article POST store allow or deny get request handle request do some stuff return response
  • 36. #4 - Form Request Routes Middleware Controller /api/article GET index /api/article POST store allow or deny get request do some stuff return response Form Request handle request - validation - authorization
  • 37. #4 - Form Request Routes Middleware Controller /api/article GET index /api/article POST store allow or deny get request do some stuff return response Form Request handle request - validation - authorization
  • 38. #4 - Form Request php artisan make:request StoreEventMemberRequest
  • 39. #4 - Form Request namespace AppHttpRequests; use IlluminateFoundationHttpFormRequest; class StoreEventMemberRequest extends FormRequest { public function authorize() { return false; } public function rules() { return [ ]; } }
  • 40. #4 - Form Request class StoreEventMemberRequest extends FormRequest { public function authorize() { return true; } public function rules() { return [ ]; } }
  • 41. #4 - Form Request class StoreEventMemberRequest extends FormRequest { public function authorize() { return true; } }
  • 42. #4 - Form Request class StoreEventMemberRequest extends FormRequest { public function authorize() { return $this->ajax(); } } true => access false => 403
  • 43. #4 - Form Request class StoreEventMemberRequest extends FormRequest { public function authorize() { return $this->ajax(); } } protected function failedAuthorization() { throw new HttpResponseException($this->forbiddenResponse()); } true => access false => 403
  • 44. #4 - Form Request class StoreEventMemberRequest extends FormRequest { public function authorize() { return true; } public function rules() { return [ 'first_name' => 'required|max:191', 'last_name' => 'required|max:191', 'department_id' => 'required|exists:departments,id', 'note' => 'max:512', ]; } }
  • 45. #4 - Form Request public function messages() { return [ ‘first_name.required’ => ‘Your first name is required’, ‘last_name.required’ => ‘Your last name is required’, ]; }
  • 46. #4 - Form Request public function attributes() { return [ ‘first_name’ => ‘Your first name’, ‘last_name’ => ‘Your last name’, ]; }
  • 47. #4 - Form Request public function withValidator($validator) { $validator->after(function ($validator) { if ($this->somethingElseIsInvalid()) { $validator->errors()->add('field', 'Something is wrong with this field!'); } }); }
  • 48. #4 - Form Request use AppHttpControllersController; use IlluminateHttpRequest; use AppHttpRequestsStoreEventMemberRequest; class EventController extends Controller { }
  • 49. #4 - Form Request public function store(StoreEventMemberRequest $request) { //authorize the request access(?) //check if request has valid data //store the event member //give some response }
  • 50. #4 - Form Request //authorize the request access(?) abort_if(!$request->ajax(), 403); //check if request has valid data $request->validate([ 'first_name' => 'required|max:191', 'last_name' => 'required|max:191', 'department_id' => 'required|exists:departments,id', 'note' => 'max:512', ]); //store the event member EventMember::create($request->all()); //give some response return [ ‘success’ => true, ];
  • 51. #4 - Form Request //authorize the request access(?) abort_if(!$request->ajax(), 403); //check if request has valid data $request->validate([ 'first_name' => 'required|max:191', 'last_name' => 'required|max:191', 'department_id' => 'required|exists:departments,id', 'note' => 'max:512', ]); //store the event member EventMember::create($request->all()); //give some response return [ ‘success’ => true, ];
  • 52. #4 - Form Request public function store(StoreEventMemberRequest $request) { EventMember::create($request->all()); return [ ‘success’ => true, ]; }
  • 53. #4 - Form Request
  • 54. #4 - Form Request Czy pozwala na więcej?!
  • 55. #4 - Form Request ● Oczyszczanie danych formularza (sanitizing) ● Manipulacja danymi formularza (handling) ● Logowanie zdarzeń (logging)
  • 56. #5 - Zastosowanie Form Request w projekcie ● Oczyszczanie danych formularza (sanitizing) ● Manipulacja danymi formularza (handling) ● Logowanie zdarzeń (logging)
  • 57. #5 - Zastosowanie Form Request w projekcie public function all() { }
  • 58. #5 - Zastosowanie Form Request w projekcie public function all() { $attributes = parent::all(); return collect($attributes) ->map(function($field) { return $field ?? filter_var($field, FILTER_SANITIZE_STRING); }) ->all(); }
  • 59. #5 - Zastosowanie Form Request w projekcie public function all() { $attributes = parent::all(); return collect($attributes) ->map(function($field) { return $field ?? filter_var($field, FILTER_SANITIZE_STRING); }) ->all(); } $_POST[‘data’] = [...]; 422 (Unprocessable Entity)
  • 60. #5 - Zastosowanie Form Request w projekcie public function all() { $attributes = parent::all(); return collect($attributes) ->map(function($field) { return $field ?? filter_var($field, FILTER_SANITIZE_STRING); }) ->all(); } $_POST[‘data’] = [...]; 422 (Unprocessable Entity) public function response(array $errors) { if ($this->ajax() || $this->wantsJson()) { return new JsonResponse($errors, 422); } return $this->redirector->to($this->getRedirectUrl()) ->withInput($this->except($this->dontFlash)) ->withErrors($errors, $this->errorBag); }
  • 61. #5 - Zastosowanie Form Request w projekcie public function all() { $attributes = parent::all(); return $this->sanitizeAttributes($attributes); } $_POST[‘data’] = [...]; protected function sanitizeAttributes($attributes) { return collect($attributes) ->map(function($field) { return $field ?? filter_var($field, FILTER_SANITIZE_STRING); }) ->all(); }
  • 62. #5 - Zastosowanie Form Request w projekcie public function all() { $attributes = $this->input('data'); $attributes['token'] = $this->input('token'); return $this->sanitizeAttributes($attributes); }
  • 63. #5 - Zastosowanie Form Request w projekcie public function all() { return $this->sanitizeAttributes($this->handleAttributes()); } protected function handleAttributes() { $attributes = $this->input('data'); $attributes['token'] = $this- >input('token'); return $attributes; }
  • 64. #5 - Zastosowanie Form Request w projekcie public function all() { return $this->sanitizeAttributes($this->handleAttributes()); } protected function handleAttributes() { if(!$this->has(‘data’)) { return parent::all(); } $attributes = $this->input('data'); $attributes['token'] = $this->input('token'); return $attributes; }
  • 65. #6 - Podsumowanie Zalety ● Clean code ● Dependency Injection ● Security ● Reusability
  • 66. #6 - Podsumowanie Wady ● Łamie SRP (Single Responsibility Principle) ● Przesadne używanie Form Request

Editor's Notes

  1. wskazuje na kontroller/metoda weryfikuje sposób przesyłania danych / post, get, etc. umożliwia walidację przesyłanych zmiennych - wzorce tworzenie nazw routów -> generowanie urli
  2. Middleware - warstwa aplikacji, która jest odpowiedzialna za filtrowanie żądania HTTP, middleware może również być wykorzystywany przy response dodanie nagłówków logowanie zdarzeń wskazanie middleware w routes
  3. handle request - validation, auth, do some stuff
  4. routes + middleware = mur obronny ale skupmy się na kontrolerze
  5. REST API schema
  6. Wstrzykiwanie zależności (ang. Dependency Injection, DI) – wzorzec projektowy i wzorzec architektury oprogramowania polegający na usuwaniu bezpośrednich zależności pomiędzy komponentami na rzecz architektury typu plug-in. Polega na przekazywaniu gotowych, utworzonych instancji obiektów udostępniających swoje metody i właściwości obiektom, które z nich korzystają (np. jako parametry konstruktora). Stanowi alternatywę do podejścia, gdzie obiekty tworzą instancję obiektów, z których korzystają np. we własnym konstruktorze.
  7. Posiada wbudowaną logikę walidacji ustalanie reguł tworzenie custom rules tworzenie custom messages on fail tworzenie custom response on fail
  8. form request - ma właściwości middleware i przejmuje zadanie kontrollera
  9. Determine if the user is authorized to make this request
  10. Determine if the user is authorized to make this request
  11. Determine if the user is authorized to make this request
  12. Adding After Hooks To Form Requests
  13. tu również pokazać, że mogłaby być dodatkowa weryfikacja, czy user może wykonać daną akcję, czy zapytanie jest ajaxowe etc.
  14. tak wygląda kod bez form request
  15. kod po zastosowaniu form request
  16. czy możemy zastosować form request do czegoś jeszcze? pytanie do słuchaczy
  17. czy możemy zastosować form request do czegoś jeszcze? pytanie do słuchaczy
  18. metoda Request all()
  19. FILTER_SANITIZE_STRING = Strip tags, optionally strip or encode special characters
  20. The server understands the content type of the request entity (hence a 415 Unsupported Media Type status code is inappropriate), and the syntax of the request entity is correct (thus a 400 Bad Request status code is inappropriate) but was unable to process the contained instructions. For example, this error condition may occur if an XML request body contains well-formed (i.e., syntactically correct), but semantically erroneous, XML instructions.
  21. Clean code: mniej kodu, rozdzielenie metod SRP (Zasada jednej odpowiedzialności) Klasa powinna mieć tylko jedną odpowiedzialność (nigdy nie powinien istnieć więcej niż jeden powód do modyfikacji klasy).
  22. Clean code: mniej kodu, rozdzielenie metod SRP (Zasada jednej odpowiedzialności) Klasa powinna mieć tylko jedną odpowiedzialność (nigdy nie powinien istnieć więcej niż jeden powód do modyfikacji klasy).