SlideShare a Scribd company logo
1 of 66
Download to read offline
To put it simply, Repository pattern is a kind of
container where data access logic is stored. It hides the
details of data access logic from business logic. In other
words, we allow business logic to access the data object
without having knowledge of underlying data access
architecture. Mar 7, 2015
https://bosnadev.com/2015/03/07/using-repository-pattern-in-laravel-5
https://bosnadev.com/2015/03/07/using-repository-pattern-in-laravel-5
andersao/l5-repository
├──
├──
├──
├──
├──
├──
├──
http://kamranahmed.info/blog/2015/12/03/creating-a-modular-application-in-laravel
├──
├──
├──
├──
├──
├──
├──
├──
├──
├──
├──
├──
├──
├──
public function newDeal(Request $request) {
$data = $request->all();
// some stuff
$page = "new_deal/new_deal_" . $data['page'];
return view($page, [
'active_step' => $data['page'],
'template_step' => 'app_deal_steps',
'origin' => 'new_deal',
'title' => 'New Deal',
'customers' => new AppDeals(),
]);
}
public function newDeal(Request $request) {
$data = $request->all();
// some stuff
$page = "new_deal/new_deal_" . $data['page'];
return view($page, [
'active_step' => $data['page'],
'template_step' => 'app_deal_steps',
'origin' => 'new_deal',
'title' => 'New Deal',
'customers' => new AppDeals(),
]);
}
X
public function newDeal(Request $request, AppDeals $deal) {
$data = $request->all();
// some stuff
$page = "new_deal/new_deal_" . $data['page'];
return view($page, [
'active_step' => $data['page'],
'template_step' => 'app_deal_steps',
'origin' => 'new_deal',
'title' => 'New Deal',
'customers' => $deal,
]);
}
public function store(Request $request)
{
$result['message'] = 'Success';
try {
$data = $request->all();
$userId = Auth::user()->id;
$company = App::make(Company::class)
->where('created_by', $userId)
->first();
$company->save($data);
} catch (Exception $error) {
$result['message'] = $error->getMessage();
}
return response()->json($result);
}
$invoices = [];
foreach ($request as $each) {
$invoices[$each['send_date']] = [
'deal_id' => $each['deal_id'],
'company_id' => $companyId,
'invoice_id' => $each['invoice_id'],
'invoice_term' => Invoices::TERM_30,
'send_same_invoice' => $each['send_same_invoice'],
];
}
$invoices = [];
foreach ($request as $each) {
$invoices[$each['send_date']] = [
'deal_id' => $each['deal_id'],
'company_id' => $companyId,
'invoice_id' => $each['invoice_id'],
'invoice_term' => Invoices::TERM_30,
'send_same_invoice' => $each['send_same_invoice'],
];
}
$invoices = [];
foreach ($request as $each) {
$invoices[$each['send_date']] = [
'deal_id' => $each['deal_id'],
'company_id' => $companyId,
'invoice_id' => $each['invoice_id'],
'invoice_term' => Invoices::TERM_30,
'send_same_invoice' => $each['send_same_invoice'],
];
}
$invoices = new Collection();
foreach ($request as $each) {
$invoices->push(new Invoice([
'deal_id' => $each['deal_id'],
'company_id' => $companyId,
'invoice_id' => $each['invoice_id'],
'invoice_term' => Invoices::TERM_30,
'send_same_invoice' => $each['send_same_invoice'],
]));
}
// Retrieve the first item in the collection
$collection->get(0);
// Default value as fallback
$collection->get(0, 'default value');
// Retrieve using custom key
$collection->get('my_key');
// Custom key and fallback
$collection->get('my_key', 'default value');
// Retrieve the first item in the collection
$collection->get(0);
// Default value as fallback
$collection->get(0, 'default value');
// Retrieve using custom key
$collection->get('my_key');
// Custom key and fallback
$collection->get('my_key', 'default value');
// Retrieve the first item in the collection
$collection->get(0);
// Default value as fallback
$collection->get(0, 'default value');
// Retrieve using custom key
$collection->get('my_key');
// Custom key and fallback
$collection->get('my_key', 'default value');
// Retrieve the first item in the collection
$collection->get(0);
// Default value as fallback
$collection->get(0, 'default value');
// Retrieve using custom key
$collection->get('my_key');
// Custom key and fallback
$collection->get('my_key', 'default value');
$invoices = [];
foreach ($request as $each) {
$invoices[$each['send_date']] = [
'deal_id' => $each['deal_id'],
'company_id' => $companyId,
'invoice_id' => $each['invoice_id'],
'invoice_term' => Invoices::TERM_30,
'send_same_invoice' => $each['send_same_invoice'],
];
}
public function update(Request $request)
{
// do something
return Auth::user()->id;
}
Laravel, the right way - PHPConference 2016
Laravel, the right way - PHPConference 2016
Laravel, the right way - PHPConference 2016
Laravel, the right way - PHPConference 2016
Laravel, the right way - PHPConference 2016
Laravel, the right way - PHPConference 2016

More Related Content

What's hot

Twib in Yokoahma.pm 2010/3/5
Twib in Yokoahma.pm 2010/3/5Twib in Yokoahma.pm 2010/3/5
Twib in Yokoahma.pm 2010/3/5
Yusuke Wada
 
YAPC::Asia 2010 Twitter解析サービス
YAPC::Asia 2010 Twitter解析サービスYAPC::Asia 2010 Twitter解析サービス
YAPC::Asia 2010 Twitter解析サービス
Yusuke Wada
 
Threading
ThreadingThreading
Threading
b290572
 
Pourquoi WordPress n’est pas un CMS
Pourquoi WordPress n’est pas un CMSPourquoi WordPress n’est pas un CMS
Pourquoi WordPress n’est pas un CMS
Thomas Gasc
 

What's hot (20)

Twib in Yokoahma.pm 2010/3/5
Twib in Yokoahma.pm 2010/3/5Twib in Yokoahma.pm 2010/3/5
Twib in Yokoahma.pm 2010/3/5
 
Blog Hacks 2011
Blog Hacks 2011Blog Hacks 2011
Blog Hacks 2011
 
Password.php
Password.phpPassword.php
Password.php
 
Build your own RESTful API with Laravel
Build your own RESTful API with LaravelBuild your own RESTful API with Laravel
Build your own RESTful API with Laravel
 
YAPC::Asia 2010 Twitter解析サービス
YAPC::Asia 2010 Twitter解析サービスYAPC::Asia 2010 Twitter解析サービス
YAPC::Asia 2010 Twitter解析サービス
 
14. CodeIgniter adaugarea inregistrarilor
14. CodeIgniter adaugarea inregistrarilor14. CodeIgniter adaugarea inregistrarilor
14. CodeIgniter adaugarea inregistrarilor
 
WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress
WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress
WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress
 
4. Php MongoDB view_data
4. Php MongoDB view_data4. Php MongoDB view_data
4. Php MongoDB view_data
 
Getting out of Callback Hell in PHP
Getting out of Callback Hell in PHPGetting out of Callback Hell in PHP
Getting out of Callback Hell in PHP
 
Threading
ThreadingThreading
Threading
 
Pourquoi WordPress n’est pas un CMS
Pourquoi WordPress n’est pas un CMSPourquoi WordPress n’est pas un CMS
Pourquoi WordPress n’est pas un CMS
 
WordPress: From Antispambot to Zeroize
WordPress: From Antispambot to ZeroizeWordPress: From Antispambot to Zeroize
WordPress: From Antispambot to Zeroize
 
Laravel - PHP For artisans
Laravel - PHP For artisansLaravel - PHP For artisans
Laravel - PHP For artisans
 
07 Php Mysql Update Delete
07 Php Mysql Update Delete07 Php Mysql Update Delete
07 Php Mysql Update Delete
 
06 Php Mysql Connect Query
06 Php Mysql Connect Query06 Php Mysql Connect Query
06 Php Mysql Connect Query
 
Codeigniter : Custom Routing - Manipulate Uri
Codeigniter : Custom Routing - Manipulate UriCodeigniter : Custom Routing - Manipulate Uri
Codeigniter : Custom Routing - Manipulate Uri
 
PowerCMS X
PowerCMS XPowerCMS X
PowerCMS X
 
次世代版 PowerCMS 開発プロジェクトのご紹介
次世代版 PowerCMS 開発プロジェクトのご紹介次世代版 PowerCMS 開発プロジェクトのご紹介
次世代版 PowerCMS 開発プロジェクトのご紹介
 
Database Management - Lecture 4 - PHP and Mysql
Database Management - Lecture 4 - PHP and MysqlDatabase Management - Lecture 4 - PHP and Mysql
Database Management - Lecture 4 - PHP and Mysql
 
Example code for the SADI BMI Calculator Web Service
Example code for the SADI BMI Calculator Web ServiceExample code for the SADI BMI Calculator Web Service
Example code for the SADI BMI Calculator Web Service
 

Viewers also liked

Qualitative and quantitative methods of research
Qualitative and quantitative methods of researchQualitative and quantitative methods of research
Qualitative and quantitative methods of research
Jordan Cruz
 

Viewers also liked (14)

Control your house with the elePHPant - PHPConf2016
Control your house with the elePHPant - PHPConf2016Control your house with the elePHPant - PHPConf2016
Control your house with the elePHPant - PHPConf2016
 
Reactive Laravel - Laravel meetup Groningen
Reactive Laravel - Laravel meetup GroningenReactive Laravel - Laravel meetup Groningen
Reactive Laravel - Laravel meetup Groningen
 
Software Design Patterns in Laravel by Phill Sparks
Software Design Patterns in Laravel by Phill SparksSoftware Design Patterns in Laravel by Phill Sparks
Software Design Patterns in Laravel by Phill Sparks
 
Phing - PHP Conference 2015
Phing -  PHP Conference 2015Phing -  PHP Conference 2015
Phing - PHP Conference 2015
 
7º Connecting Knowledge (PT-BR)
7º Connecting Knowledge (PT-BR)7º Connecting Knowledge (PT-BR)
7º Connecting Knowledge (PT-BR)
 
IoT powered by PHP and streams - PHPExperience2017
IoT powered by PHP and streams - PHPExperience2017IoT powered by PHP and streams - PHPExperience2017
IoT powered by PHP and streams - PHPExperience2017
 
Secciones estilos encabezados
Secciones estilos encabezadosSecciones estilos encabezados
Secciones estilos encabezados
 
scdevsumit 2016 - Become a jedi with php streams
scdevsumit 2016 - Become a jedi with php streamsscdevsumit 2016 - Become a jedi with php streams
scdevsumit 2016 - Become a jedi with php streams
 
TDC São Paulo 2016 - Become a jedi with php streams
TDC São Paulo 2016 - Become a jedi with php streamsTDC São Paulo 2016 - Become a jedi with php streams
TDC São Paulo 2016 - Become a jedi with php streams
 
Thirteen ways of looking at a turtle
Thirteen ways of looking at a turtleThirteen ways of looking at a turtle
Thirteen ways of looking at a turtle
 
Laravel and SOLR
Laravel and SOLRLaravel and SOLR
Laravel and SOLR
 
Domain Driven Design using Laravel
Domain Driven Design using LaravelDomain Driven Design using Laravel
Domain Driven Design using Laravel
 
Todos os passos para a certificação PHP - PHPExperience2017
Todos os passos para a certificação PHP - PHPExperience2017 Todos os passos para a certificação PHP - PHPExperience2017
Todos os passos para a certificação PHP - PHPExperience2017
 
Qualitative and quantitative methods of research
Qualitative and quantitative methods of researchQualitative and quantitative methods of research
Qualitative and quantitative methods of research
 

Similar to Laravel, the right way - PHPConference 2016

Similar to Laravel, the right way - PHPConference 2016 (20)

Writing Sensible Code
Writing Sensible CodeWriting Sensible Code
Writing Sensible Code
 
Let's write secure Drupal code!
Let's write secure Drupal code!Let's write secure Drupal code!
Let's write secure Drupal code!
 
Zero to SOLID
Zero to SOLIDZero to SOLID
Zero to SOLID
 
CakePHP workshop
CakePHP workshopCakePHP workshop
CakePHP workshop
 
Let's write secure Drupal code! - DrupalCamp Oslo, 2018
Let's write secure Drupal code! - DrupalCamp Oslo, 2018Let's write secure Drupal code! - DrupalCamp Oslo, 2018
Let's write secure Drupal code! - DrupalCamp Oslo, 2018
 
Introduction to Zend Framework web services
Introduction to Zend Framework web servicesIntroduction to Zend Framework web services
Introduction to Zend Framework web services
 
Extbase and Beyond
Extbase and BeyondExtbase and Beyond
Extbase and Beyond
 
Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2
 
Daily notes
Daily notesDaily notes
Daily notes
 
Smarty
SmartySmarty
Smarty
 
Separation of concerns - DPC12
Separation of concerns - DPC12Separation of concerns - DPC12
Separation of concerns - DPC12
 
Miniproject on Employee Management using Perl/Database.
Miniproject on Employee Management using Perl/Database.Miniproject on Employee Management using Perl/Database.
Miniproject on Employee Management using Perl/Database.
 
Let's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, Germany
Let's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, GermanyLet's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, Germany
Let's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, Germany
 
Alberto López: Candies for everybody: hacking from 9 a.m. to 6 p.m.
Alberto López: Candies for everybody: hacking from 9 a.m. to 6 p.m.Alberto López: Candies for everybody: hacking from 9 a.m. to 6 p.m.
Alberto López: Candies for everybody: hacking from 9 a.m. to 6 p.m.
 
Candies for everybody - Meet Magento Italia 2015
Candies for everybody - Meet Magento Italia 2015Candies for everybody - Meet Magento Italia 2015
Candies for everybody - Meet Magento Italia 2015
 
Bag Of Tricks From Iusethis
Bag Of Tricks From IusethisBag Of Tricks From Iusethis
Bag Of Tricks From Iusethis
 
Let's write secure drupal code!
Let's write secure drupal code!Let's write secure drupal code!
Let's write secure drupal code!
 
Practical PHP by example Jan Leth-Kjaer
Practical PHP by example   Jan Leth-KjaerPractical PHP by example   Jan Leth-Kjaer
Practical PHP by example Jan Leth-Kjaer
 
Zend framework service
Zend framework serviceZend framework service
Zend framework service
 
Zend framework service
Zend framework serviceZend framework service
Zend framework service
 

More from Matheus Marabesi

More from Matheus Marabesi (14)

IoT Project postmortem
IoT Project postmortemIoT Project postmortem
IoT Project postmortem
 
Testing with Laravel - 7Masters 2018 (Laravel)
Testing with Laravel - 7Masters 2018 (Laravel)Testing with Laravel - 7Masters 2018 (Laravel)
Testing with Laravel - 7Masters 2018 (Laravel)
 
Laravel collections an overview - Laravel SP
Laravel collections an overview - Laravel SPLaravel collections an overview - Laravel SP
Laravel collections an overview - Laravel SP
 
Becoming an author - Sharing knowledge
Becoming an author - Sharing knowledgeBecoming an author - Sharing knowledge
Becoming an author - Sharing knowledge
 
Docker 101 - Getting started
Docker 101 - Getting startedDocker 101 - Getting started
Docker 101 - Getting started
 
Introduction to IoT and PHP - Nerdzão day #1
Introduction to IoT and PHP - Nerdzão day #1Introduction to IoT and PHP - Nerdzão day #1
Introduction to IoT and PHP - Nerdzão day #1
 
GDG Passo fundo - Apps with unit tests (Karma + jasmine + angular)
GDG Passo fundo - Apps with unit tests (Karma + jasmine + angular)GDG Passo fundo - Apps with unit tests (Karma + jasmine + angular)
GDG Passo fundo - Apps with unit tests (Karma + jasmine + angular)
 
7masters - MongoDb
7masters - MongoDb7masters - MongoDb
7masters - MongoDb
 
CK 10 - Automate all the things 2.0
CK 10 - Automate all the things 2.0CK 10 - Automate all the things 2.0
CK 10 - Automate all the things 2.0
 
TDC 2015 - Wearables no IoT (PT-BR)
TDC 2015 - Wearables no IoT (PT-BR)TDC 2015 - Wearables no IoT (PT-BR)
TDC 2015 - Wearables no IoT (PT-BR)
 
From legacy code to continuous integration
From legacy code to continuous integrationFrom legacy code to continuous integration
From legacy code to continuous integration
 
Introduction to TDD (PHPunit examples)
Introduction to TDD (PHPunit examples)Introduction to TDD (PHPunit examples)
Introduction to TDD (PHPunit examples)
 
Arduino day 2015 - UFABC (PT-BR)
Arduino day 2015 - UFABC (PT-BR)Arduino day 2015 - UFABC (PT-BR)
Arduino day 2015 - UFABC (PT-BR)
 
Web Sockets - HTML5
Web Sockets - HTML5Web Sockets - HTML5
Web Sockets - HTML5
 

Recently uploaded

➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
nirzagarg
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
ydyuyu
 
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Chandigarh Call girls 9053900678 Call girls in Chandigarh
 
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
@Chandigarh #call #Girls 9053900678 @Call #Girls in @Punjab 9053900678
 
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRLLucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
imonikaupta
 

Recently uploaded (20)

VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
 
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
 
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
 
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
 
Russian Call Girls in %(+971524965298 )# Call Girls in Dubai
Russian Call Girls in %(+971524965298  )#  Call Girls in DubaiRussian Call Girls in %(+971524965298  )#  Call Girls in Dubai
Russian Call Girls in %(+971524965298 )# Call Girls in Dubai
 
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
 
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
 
Real Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirtReal Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirt
 
Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...
Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...
Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
 
Katraj ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For S...
Katraj ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For S...Katraj ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For S...
Katraj ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For S...
 
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
 
Al Barsha Night Partner +0567686026 Call Girls Dubai
Al Barsha Night Partner +0567686026 Call Girls  DubaiAl Barsha Night Partner +0567686026 Call Girls  Dubai
Al Barsha Night Partner +0567686026 Call Girls Dubai
 
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
 
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
 
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
 
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
 
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
 
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRLLucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
 

Laravel, the right way - PHPConference 2016

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11. To put it simply, Repository pattern is a kind of container where data access logic is stored. It hides the details of data access logic from business logic. In other words, we allow business logic to access the data object without having knowledge of underlying data access architecture. Mar 7, 2015 https://bosnadev.com/2015/03/07/using-repository-pattern-in-laravel-5
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 36.
  • 37. public function newDeal(Request $request) { $data = $request->all(); // some stuff $page = "new_deal/new_deal_" . $data['page']; return view($page, [ 'active_step' => $data['page'], 'template_step' => 'app_deal_steps', 'origin' => 'new_deal', 'title' => 'New Deal', 'customers' => new AppDeals(), ]); }
  • 38. public function newDeal(Request $request) { $data = $request->all(); // some stuff $page = "new_deal/new_deal_" . $data['page']; return view($page, [ 'active_step' => $data['page'], 'template_step' => 'app_deal_steps', 'origin' => 'new_deal', 'title' => 'New Deal', 'customers' => new AppDeals(), ]); } X
  • 39. public function newDeal(Request $request, AppDeals $deal) { $data = $request->all(); // some stuff $page = "new_deal/new_deal_" . $data['page']; return view($page, [ 'active_step' => $data['page'], 'template_step' => 'app_deal_steps', 'origin' => 'new_deal', 'title' => 'New Deal', 'customers' => $deal, ]); }
  • 40. public function store(Request $request) { $result['message'] = 'Success'; try { $data = $request->all(); $userId = Auth::user()->id; $company = App::make(Company::class) ->where('created_by', $userId) ->first(); $company->save($data); } catch (Exception $error) { $result['message'] = $error->getMessage(); } return response()->json($result); }
  • 41.
  • 42. $invoices = []; foreach ($request as $each) { $invoices[$each['send_date']] = [ 'deal_id' => $each['deal_id'], 'company_id' => $companyId, 'invoice_id' => $each['invoice_id'], 'invoice_term' => Invoices::TERM_30, 'send_same_invoice' => $each['send_same_invoice'], ]; }
  • 43. $invoices = []; foreach ($request as $each) { $invoices[$each['send_date']] = [ 'deal_id' => $each['deal_id'], 'company_id' => $companyId, 'invoice_id' => $each['invoice_id'], 'invoice_term' => Invoices::TERM_30, 'send_same_invoice' => $each['send_same_invoice'], ]; }
  • 44. $invoices = []; foreach ($request as $each) { $invoices[$each['send_date']] = [ 'deal_id' => $each['deal_id'], 'company_id' => $companyId, 'invoice_id' => $each['invoice_id'], 'invoice_term' => Invoices::TERM_30, 'send_same_invoice' => $each['send_same_invoice'], ]; }
  • 45. $invoices = new Collection(); foreach ($request as $each) { $invoices->push(new Invoice([ 'deal_id' => $each['deal_id'], 'company_id' => $companyId, 'invoice_id' => $each['invoice_id'], 'invoice_term' => Invoices::TERM_30, 'send_same_invoice' => $each['send_same_invoice'], ])); }
  • 46. // Retrieve the first item in the collection $collection->get(0); // Default value as fallback $collection->get(0, 'default value'); // Retrieve using custom key $collection->get('my_key'); // Custom key and fallback $collection->get('my_key', 'default value');
  • 47. // Retrieve the first item in the collection $collection->get(0); // Default value as fallback $collection->get(0, 'default value'); // Retrieve using custom key $collection->get('my_key'); // Custom key and fallback $collection->get('my_key', 'default value');
  • 48. // Retrieve the first item in the collection $collection->get(0); // Default value as fallback $collection->get(0, 'default value'); // Retrieve using custom key $collection->get('my_key'); // Custom key and fallback $collection->get('my_key', 'default value');
  • 49. // Retrieve the first item in the collection $collection->get(0); // Default value as fallback $collection->get(0, 'default value'); // Retrieve using custom key $collection->get('my_key'); // Custom key and fallback $collection->get('my_key', 'default value');
  • 50. $invoices = []; foreach ($request as $each) { $invoices[$each['send_date']] = [ 'deal_id' => $each['deal_id'], 'company_id' => $companyId, 'invoice_id' => $each['invoice_id'], 'invoice_term' => Invoices::TERM_30, 'send_same_invoice' => $each['send_same_invoice'], ]; }
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60. public function update(Request $request) { // do something return Auth::user()->id; }