SlideShare a Scribd company logo
Study Program of Information Systems
Faculty of Engineering and Computer Science
SY. 2020-2021
Andi Nurkholis, S.Kom., M.Kom.
November 09, 2020
2
3
A database is an organized collection of structured
information, or data, typically stored electronically in a
computer system. A database is usually controlled by a
database management system (DBMS)
4
Currently, Laravel
supports four databases:
• MySQL 5.6+
• PostgreSQL 9.4+
• SQLite 3.8.8+
• SQL Server 2017+
Laravel makes interacting with databases
extremely simple across a variety of database
backends using either raw SQL, the fluent query
builder, and the Eloquent ORM.
5
The database configuration for your application is located
at config/database.php.
In this file you may define all of your database
connections, as well as specify which connection should
be used by default.6
7
Laravel has a pretty simple way to define database
config, All configuration that you should stay private and
should not share goes into the .env file of your laravel
project.
Migrations are like version control for your database, allowing
your team to modify and share the application's database schema.
Migrations are typically paired with Laravel's schema builder to
build your application's database schema.
8
To create a migration, use the make:migration Artisan
command:
The new migration will be placed in your
database/migrations directory. Each migration file name
contains a timestamp, which allows Laravel to determine
the order of the migrations.
9
10
Laravel includes a simple method of seeding
your database with test data using seed classes.
All seed classes are stored in the
database/seeders directory.
To generate a seeder, execute the make:seeder
Artisan command. All seeders generated by the
framework will be placed in the
database/seeders directory:
A seeder class only contains one method by
default: run. This method is called when the
db:seed Artisan command is executed. Within
the run method, you may insert data into your
database however you wish
11
Laravel's database query builder provides a convenient,
fluent interface to creating and running database
queries. It can be used to perform most database
operations in your application and works on all
supported database systems.
12
You may use the table method on the DB facade to begin a query.
The table method returns a fluent query builder instance for the
given table, allowing you to chain more constraints onto the
query and then finally get the results using the get method:
13
14
The Model corresponds to the letter ‘M’ in the MVC framework. The
motive of Models in any Model view controller framework web
application is to manage business logic. A Model is nothing but a
class in the Laravel framework. This class is responsible to
interact with underlying database tables.
Models typically live in the appModels directory, but you
are free to place them anywhere that can be auto-loaded
according to your composer.json file. All Eloquent
models extend IlluminateDatabaseEloquentModel
class.
The easiest way to create a model instance is using the
make:model Artisan command:
15
16
The Eloquent ORM included with Laravel
provides a beautiful, simple ActiveRecord
implementation for working with your database.
Each database table has a corresponding
"Model" which is used to interact with that table.
We can work in Eloquent with database
efficiently using an ActiveMethod
implementation.
It is an architectural pattern where the model
created in the Model-View-Controller (MVC)
structure corresponds to a table in the
database.
The advantage is for models to perform
common database operations without coding
lengthy SQL queries.17
Andi Nurkholis, S.Kom., M.Kom.
September 28, 2020November 09, 2020
Study Program of Information Systems
Faculty of Engineering and Computer Science
SY. 2020-2021

More Related Content

PDF
Web Programming - 10 JavaScript
PDF
Web Programming - 7 Blading Template
PDF
Web Programming - 6 Bootstrap Framework
PDF
Web Programming - 9 Create, Read, Update and Delete
PDF
Web Programming - 4 Route, View, and Controller
PDF
Web Programming - 11 SweetAlert2, DataTables, and WYSIWYG API
PPTX
Continuous Deployment with SSDT
DOCX
Oracle jet
Web Programming - 10 JavaScript
Web Programming - 7 Blading Template
Web Programming - 6 Bootstrap Framework
Web Programming - 9 Create, Read, Update and Delete
Web Programming - 4 Route, View, and Controller
Web Programming - 11 SweetAlert2, DataTables, and WYSIWYG API
Continuous Deployment with SSDT
Oracle jet

What's hot (20)

PPTX
Sq lite
PPSX
Asp.net Overview
PPTX
Mvc Brief Overview
PDF
Struts presentation
PDF
GAB 2019 - Integrate Microsoft Graph​ with Azure Active Directory​ in your cl...
PDF
Model View Controller (MVC)
PPT
Struts(mrsurwar) ppt
PDF
Principles of MVC for Rails Developers
PPT
MVC Architecture
PPTX
An overview of microsoft mvc dot net
PPT
Asp.net mvc
PPT
4) databases
PPTX
Intern project_presentation_news_app
PDF
Introduction to Struts 1.3
PPT
Dssv1.0
PPTX
Efficient Spring Data REST Development
PPTX
Struts introduction
PDF
Asp 1a-aspnetmvc
PDF
M6 l8-ajax-handout
Sq lite
Asp.net Overview
Mvc Brief Overview
Struts presentation
GAB 2019 - Integrate Microsoft Graph​ with Azure Active Directory​ in your cl...
Model View Controller (MVC)
Struts(mrsurwar) ppt
Principles of MVC for Rails Developers
MVC Architecture
An overview of microsoft mvc dot net
Asp.net mvc
4) databases
Intern project_presentation_news_app
Introduction to Struts 1.3
Dssv1.0
Efficient Spring Data REST Development
Struts introduction
Asp 1a-aspnetmvc
M6 l8-ajax-handout
Ad

Similar to Web Programming - 8 Database, Model and Eloquent (20)

PDF
Object Oriented Programming with Laravel - Session 6
PDF
Getting to know Laravel 5
PPTX
Laravel Tutorial PPT
PPTX
What-is-Laravel and introduciton to Laravel
PDF
Object Oriented Programming with Laravel - Session 5
PPTX
What-is-Laravel-23-August-2017.pptx
PDF
Web Development with Laravel 5
PPTX
Introduction to Laravel Framework (5.2)
PPTX
Introduction to laravel framework
PPTX
Laravel
PPTX
Laravel ppt
PDF
Laravel
PDF
Laravel 4 presentation
PDF
Laravel Level 1 (The Basic)
PDF
What makes Laravel the optimal framework for your project.pdf
PPTX
Intro to Laravel
PDF
Laravel - A Trending PHP Framework
PPTX
Laravel - Website Development in Php Framework.
PDF
Laravel and Django and Rails, Oh My!
PPTX
Laravel 5
Object Oriented Programming with Laravel - Session 6
Getting to know Laravel 5
Laravel Tutorial PPT
What-is-Laravel and introduciton to Laravel
Object Oriented Programming with Laravel - Session 5
What-is-Laravel-23-August-2017.pptx
Web Development with Laravel 5
Introduction to Laravel Framework (5.2)
Introduction to laravel framework
Laravel
Laravel ppt
Laravel
Laravel 4 presentation
Laravel Level 1 (The Basic)
What makes Laravel the optimal framework for your project.pdf
Intro to Laravel
Laravel - A Trending PHP Framework
Laravel - Website Development in Php Framework.
Laravel and Django and Rails, Oh My!
Laravel 5
Ad

More from AndiNurkholis1 (20)

PDF
Technopreneurship - 9 Analisis Biaya dan Keuangan
PDF
Pengantar Bisnis - 14 Manajemen Keuangan
PDF
Pengantar Bisnis - 13 Manajemen Operasi
PDF
Pengantar Bisnis - 12 Kebijakan Harga
PDF
Pengantar Bisnis - 11 Kebijakan Distribusi
PDF
Technopreneurship - 8 Manajemen Sumber Daya Manusia
PDF
Pengantar Bisnis - 10 Kebijakan Produk
PDF
Technopreneurship - 7 Manajemen Pemasaran dan Operasional Bisnis
PDF
Pengantar Bisnis - 9 Manajemen Pemasaran
PDF
Technopreneurship - 6 Business Plan
PDF
Pengantar Bisnis - 8 Kepemimpinan
PDF
Technopreneurship - 5 Model Bisnis
PDF
Technopreneurship - 4 Studi Kelayakan Usaha
PDF
Pengantar Bisnis - 7 Motivasi Kerja
PDF
Pengantar Bisnis - 6 Manajemen Sumber Daya Manusia
PDF
Pengantar Bisnis - 5 Pengelolaan & Pengorganisasian Bisnis
PDF
Technopreneurship - 3 Ide dan Prinsip Bisnis
PDF
Pengantar Bisnis - 4 Bentuk Organisasi Bisnis
PDF
Technopreneurship - 2 Pengantar Technopreneurship
PDF
Pengantar Bisnis - 3 Globalisasi Ekonomi & Bisnis Internasional
Technopreneurship - 9 Analisis Biaya dan Keuangan
Pengantar Bisnis - 14 Manajemen Keuangan
Pengantar Bisnis - 13 Manajemen Operasi
Pengantar Bisnis - 12 Kebijakan Harga
Pengantar Bisnis - 11 Kebijakan Distribusi
Technopreneurship - 8 Manajemen Sumber Daya Manusia
Pengantar Bisnis - 10 Kebijakan Produk
Technopreneurship - 7 Manajemen Pemasaran dan Operasional Bisnis
Pengantar Bisnis - 9 Manajemen Pemasaran
Technopreneurship - 6 Business Plan
Pengantar Bisnis - 8 Kepemimpinan
Technopreneurship - 5 Model Bisnis
Technopreneurship - 4 Studi Kelayakan Usaha
Pengantar Bisnis - 7 Motivasi Kerja
Pengantar Bisnis - 6 Manajemen Sumber Daya Manusia
Pengantar Bisnis - 5 Pengelolaan & Pengorganisasian Bisnis
Technopreneurship - 3 Ide dan Prinsip Bisnis
Pengantar Bisnis - 4 Bentuk Organisasi Bisnis
Technopreneurship - 2 Pengantar Technopreneurship
Pengantar Bisnis - 3 Globalisasi Ekonomi & Bisnis Internasional

Recently uploaded (20)

PDF
KodekX | Application Modernization Development
PDF
madgavkar20181017ppt McKinsey Presentation.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Advanced IT Governance
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Cloud computing and distributed systems.
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Electronic commerce courselecture one. Pdf
PDF
Empathic Computing: Creating Shared Understanding
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Sensors and Actuators in IoT Systems using pdf
PPT
Teaching material agriculture food technology
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
PDF
NewMind AI Weekly Chronicles - August'25 Week I
KodekX | Application Modernization Development
madgavkar20181017ppt McKinsey Presentation.pdf
Spectral efficient network and resource selection model in 5G networks
MYSQL Presentation for SQL database connectivity
Advanced IT Governance
Diabetes mellitus diagnosis method based random forest with bat algorithm
Cloud computing and distributed systems.
Understanding_Digital_Forensics_Presentation.pptx
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Electronic commerce courselecture one. Pdf
Empathic Computing: Creating Shared Understanding
NewMind AI Monthly Chronicles - July 2025
Sensors and Actuators in IoT Systems using pdf
Teaching material agriculture food technology
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
NewMind AI Weekly Chronicles - August'25 Week I

Web Programming - 8 Database, Model and Eloquent

  • 1. Study Program of Information Systems Faculty of Engineering and Computer Science SY. 2020-2021 Andi Nurkholis, S.Kom., M.Kom. November 09, 2020
  • 2. 2
  • 3. 3 A database is an organized collection of structured information, or data, typically stored electronically in a computer system. A database is usually controlled by a database management system (DBMS)
  • 4. 4 Currently, Laravel supports four databases: • MySQL 5.6+ • PostgreSQL 9.4+ • SQLite 3.8.8+ • SQL Server 2017+
  • 5. Laravel makes interacting with databases extremely simple across a variety of database backends using either raw SQL, the fluent query builder, and the Eloquent ORM. 5
  • 6. The database configuration for your application is located at config/database.php. In this file you may define all of your database connections, as well as specify which connection should be used by default.6
  • 7. 7 Laravel has a pretty simple way to define database config, All configuration that you should stay private and should not share goes into the .env file of your laravel project.
  • 8. Migrations are like version control for your database, allowing your team to modify and share the application's database schema. Migrations are typically paired with Laravel's schema builder to build your application's database schema. 8
  • 9. To create a migration, use the make:migration Artisan command: The new migration will be placed in your database/migrations directory. Each migration file name contains a timestamp, which allows Laravel to determine the order of the migrations. 9
  • 10. 10 Laravel includes a simple method of seeding your database with test data using seed classes. All seed classes are stored in the database/seeders directory.
  • 11. To generate a seeder, execute the make:seeder Artisan command. All seeders generated by the framework will be placed in the database/seeders directory: A seeder class only contains one method by default: run. This method is called when the db:seed Artisan command is executed. Within the run method, you may insert data into your database however you wish 11
  • 12. Laravel's database query builder provides a convenient, fluent interface to creating and running database queries. It can be used to perform most database operations in your application and works on all supported database systems. 12
  • 13. You may use the table method on the DB facade to begin a query. The table method returns a fluent query builder instance for the given table, allowing you to chain more constraints onto the query and then finally get the results using the get method: 13
  • 14. 14 The Model corresponds to the letter ‘M’ in the MVC framework. The motive of Models in any Model view controller framework web application is to manage business logic. A Model is nothing but a class in the Laravel framework. This class is responsible to interact with underlying database tables.
  • 15. Models typically live in the appModels directory, but you are free to place them anywhere that can be auto-loaded according to your composer.json file. All Eloquent models extend IlluminateDatabaseEloquentModel class. The easiest way to create a model instance is using the make:model Artisan command: 15
  • 16. 16 The Eloquent ORM included with Laravel provides a beautiful, simple ActiveRecord implementation for working with your database. Each database table has a corresponding "Model" which is used to interact with that table.
  • 17. We can work in Eloquent with database efficiently using an ActiveMethod implementation. It is an architectural pattern where the model created in the Model-View-Controller (MVC) structure corresponds to a table in the database. The advantage is for models to perform common database operations without coding lengthy SQL queries.17
  • 18. Andi Nurkholis, S.Kom., M.Kom. September 28, 2020November 09, 2020 Study Program of Information Systems Faculty of Engineering and Computer Science SY. 2020-2021