SlideShare a Scribd company logo
1 of 15
Laravel 5.3
Directory Changes
• Route folder (api - web - console )
• Assets have a js Folder
• Folder events, policies , console and listeners was removed
• Web file now under middleware web
• Api file under prefix api and middleware api
New Query Builder
Now DB class return with collection rather than array
Example :
DB::table(‘user ’)->get() ;
New Global Cache Method
Like session(), the cache() global helper can perform three primary functions: get, put, or return an instance
of the backing service
For example:
● cache('abc', null) gets the cached value of abc, or an optional fallback of null
● cache(['abc' => 'def'], 5) sets the value of abc to def, for the duration of 5 minutes
● cache() returns an instance of the CacheManager
New Custom Pagination View
How it works:
• Just run
php artisan vendor:publish
• Edit resources/views/vendor/pagination/default.blade.php
New Mailble Class
To create new Class:
• Run command
php artisan make:mail ClassName
• Any variable defined as a public property will be available to the view
Example:
php artisan make:mail Reminder
Mail::to($user)->send(new Reminder);
<?php
namespace AppMail;
use IlluminateBusQueueable;
use IlluminateMailMailable;
use IlluminateQueueSerializesModels;
class Reminder extends Mailable
{
use Queueable, SerializesModels;
public function __construct(){ }
public function build(){
return $this->from('hello@app.com', 'Your Application')
->subject('Your Reminder!')
->view('emails.reminder');
}
}
New $loop Variable at Every Loop
The $loop variable is a stdClass object that provides meta information about the loop you're currently
inside. Take a look at the properties it exposes:
● index: the 0-based index of the current item in the loop; 0 would mean "first item"
● iteration: the 1-based index of the current item in the loop; 1 would mean "first item"
● remaining: how many items remain in the loop; if current item is first of three, would return 2
● count: the count of items in the loop
● first: boolean; whether this is the first item in the loop
● last: boolean; whether this is the last item in the loop
● depth: integer; how many "levels" deep this loop is; returns 1 for a loop, 2 for a loop within a loop, etc.
● parent: if this loop is within another @foreach loop, returns a reference to the $loop variable for the parent loop item;
otherwise returns null
@foreach ($users as $user)
@if ($loop->first)
This is the first iteration.
@endif
<p>This is user {{ $user->id }}</p>
@if ($loop->last)
This is the last iteration.
@endif
@endforeach
Many to Many Relationships has New Toggle Method
• It gives us the ability to attache item in table or remove it if it exists
• toggle() method on all belongsToMany relationships.
• This solves the issue of needing to delete a pivot table record if it exists, or adding it if it doesn’t.
• As an example, consider needing to toggle a user’s "like" status for a post
New JSON-Column where() and update() Syntax
Let's assume we have a table with a JSON column:
class CreateContactsTable extends Migration
{
public function up()
{
Schema::create('contacts', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->json('meta');
$table->timestamps();
});
}
We could imagine one contact (output to JSON for blog-post-readability) might look like this:
{"id": 1,
"name": "Alphonse",
"meta": {
"wants_newsletter": true,
"favorite_color": "red"
}}
So, let's get all of our users whose favorite color is red. As you can see below, we start with the column
(meta), followed by an arrow (->), followed by the key name of the JSON property (favorite_color).
$redLovers = DB::table('users')
->where('meta->favorite_color', 'red')
->get();
DB::table('users')
->where('id', 1)
->update(['meta->wants_newsletter' => false]);
Advanced Operations with Collection::where
If you want to filter a Laravel collection to only those records which meet particular criteria, you're most
likely going to reach for filter() or reject(). For a quick refresh, this is how you might use both:
$vips = $people->filter(function ($person) {
return $person->status === 'vip';
});
$nonVips = $people->reject(function ($person) {
return $person->status === 'vip';
});
Image Dimension Validation Rules
public function postImage(Request $request)
{
$this->validate($request, [
'avatar' => 'dimensions:min_width=250,min_height=500'
]);
$this->validate($request, [
'avatar' => 'dimensions:min_width=500,max_width=1500'
]);
$this->validate($request, [
'avatar' => 'dimensions:width=100,height=100'
]);
$this->validate($request, [
'avatar' => 'dimensions:ratio=3/2'
]);
}
laravel-53

More Related Content

What's hot

PHP - Getting good with MySQL part II
 PHP - Getting good with MySQL part II PHP - Getting good with MySQL part II
PHP - Getting good with MySQL part IIFirdaus Adib
 
Lambda functions in java 8
Lambda functions in java 8Lambda functions in java 8
Lambda functions in java 8James Brown
 
Scala - den smarta kusinen
Scala - den smarta kusinenScala - den smarta kusinen
Scala - den smarta kusinenRedpill Linpro
 
Database Connectivity in PHP
Database Connectivity in PHPDatabase Connectivity in PHP
Database Connectivity in PHPTaha Malampatti
 
POO Java Chapitre 3 Collections
POO Java Chapitre 3 CollectionsPOO Java Chapitre 3 Collections
POO Java Chapitre 3 CollectionsMouna Torjmen
 
New in cakephp3
New in cakephp3New in cakephp3
New in cakephp3markstory
 
PostgreSQL- An Introduction
PostgreSQL- An IntroductionPostgreSQL- An Introduction
PostgreSQL- An IntroductionSmita Prasad
 
Selectors and normalizing state shape
Selectors and normalizing state shapeSelectors and normalizing state shape
Selectors and normalizing state shapeMuntasir Chowdhury
 
Book integrated assignment
Book integrated assignmentBook integrated assignment
Book integrated assignmentAkash gupta
 
Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.David Gómez García
 

What's hot (20)

Building a Search Engine Using Lucene
Building a Search Engine Using LuceneBuilding a Search Engine Using Lucene
Building a Search Engine Using Lucene
 
PHP - Getting good with MySQL part II
 PHP - Getting good with MySQL part II PHP - Getting good with MySQL part II
PHP - Getting good with MySQL part II
 
Lambda functions in java 8
Lambda functions in java 8Lambda functions in java 8
Lambda functions in java 8
 
Scala - den smarta kusinen
Scala - den smarta kusinenScala - den smarta kusinen
Scala - den smarta kusinen
 
collections
collectionscollections
collections
 
Database Connectivity in PHP
Database Connectivity in PHPDatabase Connectivity in PHP
Database Connectivity in PHP
 
J query 01.07.2013.html
J query 01.07.2013.htmlJ query 01.07.2013.html
J query 01.07.2013.html
 
POO Java Chapitre 3 Collections
POO Java Chapitre 3 CollectionsPOO Java Chapitre 3 Collections
POO Java Chapitre 3 Collections
 
J query 01.07.2013
J query 01.07.2013J query 01.07.2013
J query 01.07.2013
 
4.3 MySQL + PHP
4.3 MySQL + PHP4.3 MySQL + PHP
4.3 MySQL + PHP
 
New in cakephp3
New in cakephp3New in cakephp3
New in cakephp3
 
PostgreSQL- An Introduction
PostgreSQL- An IntroductionPostgreSQL- An Introduction
PostgreSQL- An Introduction
 
Selectors and normalizing state shape
Selectors and normalizing state shapeSelectors and normalizing state shape
Selectors and normalizing state shape
 
занятие8
занятие8занятие8
занятие8
 
Java8.part2
Java8.part2Java8.part2
Java8.part2
 
Perl
PerlPerl
Perl
 
lab56_db
lab56_dblab56_db
lab56_db
 
Book integrated assignment
Book integrated assignmentBook integrated assignment
Book integrated assignment
 
Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.
 
Introduction kot iin
Introduction kot iinIntroduction kot iin
Introduction kot iin
 

Viewers also liked

G3 stoeck and_hayim_lapin_nextgenerationculturalheritage
G3 stoeck and_hayim_lapin_nextgenerationculturalheritageG3 stoeck and_hayim_lapin_nextgenerationculturalheritage
G3 stoeck and_hayim_lapin_nextgenerationculturalheritageevaminerva
 
Alteridad
AlteridadAlteridad
Alteridadcun
 
E3 wesker kuflik_novel_technologylivinglab
E3 wesker kuflik_novel_technologylivinglabE3 wesker kuflik_novel_technologylivinglab
E3 wesker kuflik_novel_technologylivinglabevaminerva
 
G7 menahem katz_hillelgershuni_textualvariants
G7 menahem katz_hillelgershuni_textualvariantsG7 menahem katz_hillelgershuni_textualvariants
G7 menahem katz_hillelgershuni_textualvariantsevaminerva
 
G7 menahem katz_hillelgershuni_textualvariants
G7 menahem katz_hillelgershuni_textualvariantsG7 menahem katz_hillelgershuni_textualvariants
G7 menahem katz_hillelgershuni_textualvariantsevaminerva
 
Presentación1 mica y vale♥
Presentación1 mica y vale♥Presentación1 mica y vale♥
Presentación1 mica y vale♥valemica
 
Oracle database 12c client installation guide 6
Oracle database 12c client installation guide 6Oracle database 12c client installation guide 6
Oracle database 12c client installation guide 6bupbechanhgmail
 
مشروع ميزانية هيئة الحقيقة والكرامة
مشروع ميزانية هيئة الحقيقة والكرامةمشروع ميزانية هيئة الحقيقة والكرامة
مشروع ميزانية هيئة الحقيقة والكرامةTunisieArp
 
Presentación intr cs 1
Presentación intr cs 1Presentación intr cs 1
Presentación intr cs 1caelerma2011
 
Trabajo final luis yovani gonzalez
Trabajo final luis yovani gonzalezTrabajo final luis yovani gonzalez
Trabajo final luis yovani gonzalezyovanigonzalez2
 
Importancia de la diersidad biologica
Importancia de la diersidad biologicaImportancia de la diersidad biologica
Importancia de la diersidad biologicaDaniel Guzmán
 
Portfolio Project - Hannah Collier
Portfolio Project - Hannah CollierPortfolio Project - Hannah Collier
Portfolio Project - Hannah CollierHannah Calley
 
E2 paulo martinez_environmentalhistory
E2 paulo martinez_environmentalhistoryE2 paulo martinez_environmentalhistory
E2 paulo martinez_environmentalhistoryevaminerva
 

Viewers also liked (17)

Final Portfolio
Final PortfolioFinal Portfolio
Final Portfolio
 
G3 stoeck and_hayim_lapin_nextgenerationculturalheritage
G3 stoeck and_hayim_lapin_nextgenerationculturalheritageG3 stoeck and_hayim_lapin_nextgenerationculturalheritage
G3 stoeck and_hayim_lapin_nextgenerationculturalheritage
 
PUESTA A TIERRA
PUESTA A TIERRAPUESTA A TIERRA
PUESTA A TIERRA
 
Humanos
HumanosHumanos
Humanos
 
Alteridad
AlteridadAlteridad
Alteridad
 
E3 wesker kuflik_novel_technologylivinglab
E3 wesker kuflik_novel_technologylivinglabE3 wesker kuflik_novel_technologylivinglab
E3 wesker kuflik_novel_technologylivinglab
 
Efecto Doppler
Efecto DopplerEfecto Doppler
Efecto Doppler
 
G7 menahem katz_hillelgershuni_textualvariants
G7 menahem katz_hillelgershuni_textualvariantsG7 menahem katz_hillelgershuni_textualvariants
G7 menahem katz_hillelgershuni_textualvariants
 
G7 menahem katz_hillelgershuni_textualvariants
G7 menahem katz_hillelgershuni_textualvariantsG7 menahem katz_hillelgershuni_textualvariants
G7 menahem katz_hillelgershuni_textualvariants
 
Presentación1 mica y vale♥
Presentación1 mica y vale♥Presentación1 mica y vale♥
Presentación1 mica y vale♥
 
Oracle database 12c client installation guide 6
Oracle database 12c client installation guide 6Oracle database 12c client installation guide 6
Oracle database 12c client installation guide 6
 
مشروع ميزانية هيئة الحقيقة والكرامة
مشروع ميزانية هيئة الحقيقة والكرامةمشروع ميزانية هيئة الحقيقة والكرامة
مشروع ميزانية هيئة الحقيقة والكرامة
 
Presentación intr cs 1
Presentación intr cs 1Presentación intr cs 1
Presentación intr cs 1
 
Trabajo final luis yovani gonzalez
Trabajo final luis yovani gonzalezTrabajo final luis yovani gonzalez
Trabajo final luis yovani gonzalez
 
Importancia de la diersidad biologica
Importancia de la diersidad biologicaImportancia de la diersidad biologica
Importancia de la diersidad biologica
 
Portfolio Project - Hannah Collier
Portfolio Project - Hannah CollierPortfolio Project - Hannah Collier
Portfolio Project - Hannah Collier
 
E2 paulo martinez_environmentalhistory
E2 paulo martinez_environmentalhistoryE2 paulo martinez_environmentalhistory
E2 paulo martinez_environmentalhistory
 

Similar to laravel-53

REST APIs in Laravel 101
REST APIs in Laravel 101REST APIs in Laravel 101
REST APIs in Laravel 101Samantha Geitz
 
Rails 3 Beautiful Code
Rails 3 Beautiful CodeRails 3 Beautiful Code
Rails 3 Beautiful CodeGreggPollack
 
あなたのScalaを爆速にする7つの方法
あなたのScalaを爆速にする7つの方法あなたのScalaを爆速にする7つの方法
あなたのScalaを爆速にする7つの方法x1 ichi
 
Functional Java 8 in everyday life
Functional Java 8 in everyday lifeFunctional Java 8 in everyday life
Functional Java 8 in everyday lifeAndrea Iacono
 
The Django Book chapter 5 Models
The Django Book chapter 5 ModelsThe Django Book chapter 5 Models
The Django Book chapter 5 ModelsVincent Chien
 
Phyton Learning extracts
Phyton Learning extracts Phyton Learning extracts
Phyton Learning extracts Pavan Babu .G
 
Ruby/Rails
Ruby/RailsRuby/Rails
Ruby/Railsrstankov
 
Programming picaresque
Programming picaresqueProgramming picaresque
Programming picaresqueBret McGuire
 
Why Task Queues - ComoRichWeb
Why Task Queues - ComoRichWebWhy Task Queues - ComoRichWeb
Why Task Queues - ComoRichWebBryan Helmig
 
Charles Sharp: Java 8 Streams
Charles Sharp: Java 8 StreamsCharles Sharp: Java 8 Streams
Charles Sharp: Java 8 Streamsjessitron
 

Similar to laravel-53 (20)

REST APIs in Laravel 101
REST APIs in Laravel 101REST APIs in Laravel 101
REST APIs in Laravel 101
 
Rails 3 Beautiful Code
Rails 3 Beautiful CodeRails 3 Beautiful Code
Rails 3 Beautiful Code
 
あなたのScalaを爆速にする7つの方法
あなたのScalaを爆速にする7つの方法あなたのScalaを爆速にする7つの方法
あなたのScalaを爆速にする7つの方法
 
Functional Java 8 in everyday life
Functional Java 8 in everyday lifeFunctional Java 8 in everyday life
Functional Java 8 in everyday life
 
Java session4
Java session4Java session4
Java session4
 
Lambdas and Laughs
Lambdas and LaughsLambdas and Laughs
Lambdas and Laughs
 
CPP homework help
CPP homework helpCPP homework help
CPP homework help
 
Java 8 Workshop
Java 8 WorkshopJava 8 Workshop
Java 8 Workshop
 
The Django Book chapter 5 Models
The Django Book chapter 5 ModelsThe Django Book chapter 5 Models
The Django Book chapter 5 Models
 
Spsl vi unit final
Spsl vi unit finalSpsl vi unit final
Spsl vi unit final
 
Spsl v unit - final
Spsl v unit - finalSpsl v unit - final
Spsl v unit - final
 
Java gets a closure
Java gets a closureJava gets a closure
Java gets a closure
 
.Net (F # ) Records, lists
.Net (F # ) Records, lists.Net (F # ) Records, lists
.Net (F # ) Records, lists
 
Intro to Rails 4
Intro to Rails 4Intro to Rails 4
Intro to Rails 4
 
Phyton Learning extracts
Phyton Learning extracts Phyton Learning extracts
Phyton Learning extracts
 
Ruby/Rails
Ruby/RailsRuby/Rails
Ruby/Rails
 
Java8
Java8Java8
Java8
 
Programming picaresque
Programming picaresqueProgramming picaresque
Programming picaresque
 
Why Task Queues - ComoRichWeb
Why Task Queues - ComoRichWebWhy Task Queues - ComoRichWeb
Why Task Queues - ComoRichWeb
 
Charles Sharp: Java 8 Streams
Charles Sharp: Java 8 StreamsCharles Sharp: Java 8 Streams
Charles Sharp: Java 8 Streams
 

laravel-53

  • 2. Directory Changes • Route folder (api - web - console ) • Assets have a js Folder • Folder events, policies , console and listeners was removed • Web file now under middleware web • Api file under prefix api and middleware api
  • 3. New Query Builder Now DB class return with collection rather than array Example : DB::table(‘user ’)->get() ;
  • 4. New Global Cache Method Like session(), the cache() global helper can perform three primary functions: get, put, or return an instance of the backing service For example: ● cache('abc', null) gets the cached value of abc, or an optional fallback of null ● cache(['abc' => 'def'], 5) sets the value of abc to def, for the duration of 5 minutes ● cache() returns an instance of the CacheManager
  • 5. New Custom Pagination View How it works: • Just run php artisan vendor:publish • Edit resources/views/vendor/pagination/default.blade.php
  • 6. New Mailble Class To create new Class: • Run command php artisan make:mail ClassName • Any variable defined as a public property will be available to the view Example: php artisan make:mail Reminder Mail::to($user)->send(new Reminder);
  • 7. <?php namespace AppMail; use IlluminateBusQueueable; use IlluminateMailMailable; use IlluminateQueueSerializesModels; class Reminder extends Mailable { use Queueable, SerializesModels; public function __construct(){ } public function build(){ return $this->from('hello@app.com', 'Your Application') ->subject('Your Reminder!') ->view('emails.reminder'); } }
  • 8. New $loop Variable at Every Loop The $loop variable is a stdClass object that provides meta information about the loop you're currently inside. Take a look at the properties it exposes: ● index: the 0-based index of the current item in the loop; 0 would mean "first item" ● iteration: the 1-based index of the current item in the loop; 1 would mean "first item" ● remaining: how many items remain in the loop; if current item is first of three, would return 2 ● count: the count of items in the loop ● first: boolean; whether this is the first item in the loop ● last: boolean; whether this is the last item in the loop ● depth: integer; how many "levels" deep this loop is; returns 1 for a loop, 2 for a loop within a loop, etc. ● parent: if this loop is within another @foreach loop, returns a reference to the $loop variable for the parent loop item; otherwise returns null
  • 9. @foreach ($users as $user) @if ($loop->first) This is the first iteration. @endif <p>This is user {{ $user->id }}</p> @if ($loop->last) This is the last iteration. @endif @endforeach
  • 10. Many to Many Relationships has New Toggle Method • It gives us the ability to attache item in table or remove it if it exists • toggle() method on all belongsToMany relationships. • This solves the issue of needing to delete a pivot table record if it exists, or adding it if it doesn’t. • As an example, consider needing to toggle a user’s "like" status for a post
  • 11. New JSON-Column where() and update() Syntax Let's assume we have a table with a JSON column: class CreateContactsTable extends Migration { public function up() { Schema::create('contacts', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->json('meta'); $table->timestamps(); }); }
  • 12. We could imagine one contact (output to JSON for blog-post-readability) might look like this: {"id": 1, "name": "Alphonse", "meta": { "wants_newsletter": true, "favorite_color": "red" }} So, let's get all of our users whose favorite color is red. As you can see below, we start with the column (meta), followed by an arrow (->), followed by the key name of the JSON property (favorite_color). $redLovers = DB::table('users') ->where('meta->favorite_color', 'red') ->get(); DB::table('users') ->where('id', 1) ->update(['meta->wants_newsletter' => false]);
  • 13. Advanced Operations with Collection::where If you want to filter a Laravel collection to only those records which meet particular criteria, you're most likely going to reach for filter() or reject(). For a quick refresh, this is how you might use both: $vips = $people->filter(function ($person) { return $person->status === 'vip'; }); $nonVips = $people->reject(function ($person) { return $person->status === 'vip'; });
  • 14. Image Dimension Validation Rules public function postImage(Request $request) { $this->validate($request, [ 'avatar' => 'dimensions:min_width=250,min_height=500' ]); $this->validate($request, [ 'avatar' => 'dimensions:min_width=500,max_width=1500' ]); $this->validate($request, [ 'avatar' => 'dimensions:width=100,height=100' ]); $this->validate($request, [ 'avatar' => 'dimensions:ratio=3/2' ]); }