SlideShare a Scribd company logo
1 of 18
Download to read offline
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

What's hot (20)

Sq lite
Sq liteSq lite
Sq lite
 
Asp.net Overview
Asp.net OverviewAsp.net Overview
Asp.net Overview
 
Mvc Brief Overview
Mvc Brief OverviewMvc Brief Overview
Mvc Brief Overview
 
Struts presentation
Struts presentationStruts presentation
Struts presentation
 
GAB 2019 - Integrate Microsoft Graph​ with Azure Active Directory​ in your cl...
GAB 2019 - Integrate Microsoft Graph​ with Azure Active Directory​ in your cl...GAB 2019 - Integrate Microsoft Graph​ with Azure Active Directory​ in your cl...
GAB 2019 - Integrate Microsoft Graph​ with Azure Active Directory​ in your cl...
 
Model View Controller (MVC)
Model View Controller (MVC)Model View Controller (MVC)
Model View Controller (MVC)
 
Struts(mrsurwar) ppt
Struts(mrsurwar) pptStruts(mrsurwar) ppt
Struts(mrsurwar) ppt
 
Principles of MVC for Rails Developers
Principles of MVC for Rails DevelopersPrinciples of MVC for Rails Developers
Principles of MVC for Rails Developers
 
MVC Architecture
MVC ArchitectureMVC Architecture
MVC Architecture
 
An overview of microsoft mvc dot net
An overview of microsoft mvc dot netAn overview of microsoft mvc dot net
An overview of microsoft mvc dot net
 
Asp.net mvc
Asp.net mvcAsp.net mvc
Asp.net mvc
 
4) databases
4) databases4) databases
4) databases
 
MVC architecture
MVC architectureMVC architecture
MVC architecture
 
Intern project_presentation_news_app
Intern project_presentation_news_appIntern project_presentation_news_app
Intern project_presentation_news_app
 
Introduction to Struts 1.3
Introduction to Struts 1.3Introduction to Struts 1.3
Introduction to Struts 1.3
 
Dssv1.0
Dssv1.0Dssv1.0
Dssv1.0
 
Efficient Spring Data REST Development
Efficient Spring Data REST DevelopmentEfficient Spring Data REST Development
Efficient Spring Data REST Development
 
Struts introduction
Struts introductionStruts introduction
Struts introduction
 
Asp 1a-aspnetmvc
Asp 1a-aspnetmvcAsp 1a-aspnetmvc
Asp 1a-aspnetmvc
 
M6 l8-ajax-handout
M6 l8-ajax-handoutM6 l8-ajax-handout
M6 l8-ajax-handout
 

Similar to Web Programming - 8 Database, Model and Eloquent

What makes Laravel the optimal framework for your project.pdf
What makes Laravel the optimal framework for your project.pdfWhat makes Laravel the optimal framework for your project.pdf
What makes Laravel the optimal framework for your project.pdfCubetTechnoLabs1
 
Latest Laravel Practice 2023 Experts Guidance.pdf
Latest Laravel Practice 2023 Experts Guidance.pdfLatest Laravel Practice 2023 Experts Guidance.pdf
Latest Laravel Practice 2023 Experts Guidance.pdfSufalam Technologies
 
Enhance Your Flask Web Project With a Database Python Guide.pdf
Enhance Your Flask Web Project With a Database  Python Guide.pdfEnhance Your Flask Web Project With a Database  Python Guide.pdf
Enhance Your Flask Web Project With a Database Python Guide.pdfInexture Solutions
 
Free Hibernate Tutorial | VirtualNuggets
Free Hibernate Tutorial  | VirtualNuggetsFree Hibernate Tutorial  | VirtualNuggets
Free Hibernate Tutorial | VirtualNuggetsVirtual Nuggets
 
Ch06 ado.net fundamentals
Ch06 ado.net fundamentalsCh06 ado.net fundamentals
Ch06 ado.net fundamentalsMadhuri Kavade
 
Frequently Asked Questions About Laravel
Frequently Asked Questions About LaravelFrequently Asked Questions About Laravel
Frequently Asked Questions About LaravelAResourcePool
 
Laravel Web Development: A Comprehensive Guide
Laravel Web Development: A Comprehensive GuideLaravel Web Development: A Comprehensive Guide
Laravel Web Development: A Comprehensive Guidedeep9753ak
 
Data Base Design.pptx
Data Base Design.pptxData Base Design.pptx
Data Base Design.pptxSunilMS21
 
What's new in laravel 9 a complete guide for laravel website development
What's new in laravel 9  a complete guide for laravel website developmentWhat's new in laravel 9  a complete guide for laravel website development
What's new in laravel 9 a complete guide for laravel website developmentMoon Technolabs Pvt. Ltd.
 
Laravel - A Trending PHP Framework
Laravel - A Trending PHP FrameworkLaravel - A Trending PHP Framework
Laravel - A Trending PHP Frameworkijtsrd
 
A introduction to oracle data integrator
A introduction to oracle data integratorA introduction to oracle data integrator
A introduction to oracle data integratorchkamal
 

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

What makes Laravel the optimal framework for your project.pdf
What makes Laravel the optimal framework for your project.pdfWhat makes Laravel the optimal framework for your project.pdf
What makes Laravel the optimal framework for your project.pdf
 
Laravel overview
Laravel overviewLaravel overview
Laravel overview
 
Latest Laravel Practice 2023 Experts Guidance.pdf
Latest Laravel Practice 2023 Experts Guidance.pdfLatest Laravel Practice 2023 Experts Guidance.pdf
Latest Laravel Practice 2023 Experts Guidance.pdf
 
Laravel Tutorial PPT
Laravel Tutorial PPTLaravel Tutorial PPT
Laravel Tutorial PPT
 
Enhance Your Flask Web Project With a Database Python Guide.pdf
Enhance Your Flask Web Project With a Database  Python Guide.pdfEnhance Your Flask Web Project With a Database  Python Guide.pdf
Enhance Your Flask Web Project With a Database Python Guide.pdf
 
cakephp UDUYKTHA (1)
cakephp UDUYKTHA (1)cakephp UDUYKTHA (1)
cakephp UDUYKTHA (1)
 
Free Hibernate Tutorial | VirtualNuggets
Free Hibernate Tutorial  | VirtualNuggetsFree Hibernate Tutorial  | VirtualNuggets
Free Hibernate Tutorial | VirtualNuggets
 
Ef code first
Ef code firstEf code first
Ef code first
 
Erciyes university
Erciyes universityErciyes university
Erciyes university
 
Ch06 ado.net fundamentals
Ch06 ado.net fundamentalsCh06 ado.net fundamentals
Ch06 ado.net fundamentals
 
PPT temp.pptx
PPT temp.pptxPPT temp.pptx
PPT temp.pptx
 
No sql database
No sql databaseNo sql database
No sql database
 
Frequently Asked Questions About Laravel
Frequently Asked Questions About LaravelFrequently Asked Questions About Laravel
Frequently Asked Questions About Laravel
 
Laravel Web Development: A Comprehensive Guide
Laravel Web Development: A Comprehensive GuideLaravel Web Development: A Comprehensive Guide
Laravel Web Development: A Comprehensive Guide
 
Data Base Design.pptx
Data Base Design.pptxData Base Design.pptx
Data Base Design.pptx
 
laravel.pptx
laravel.pptxlaravel.pptx
laravel.pptx
 
java 4 Part 1 computer science.pptx
java 4 Part 1 computer science.pptxjava 4 Part 1 computer science.pptx
java 4 Part 1 computer science.pptx
 
What's new in laravel 9 a complete guide for laravel website development
What's new in laravel 9  a complete guide for laravel website developmentWhat's new in laravel 9  a complete guide for laravel website development
What's new in laravel 9 a complete guide for laravel website development
 
Laravel - A Trending PHP Framework
Laravel - A Trending PHP FrameworkLaravel - A Trending PHP Framework
Laravel - A Trending PHP Framework
 
A introduction to oracle data integrator
A introduction to oracle data integratorA introduction to oracle data integrator
A introduction to oracle data integrator
 

More from AndiNurkholis1

Mobile Programming - 10 Firebase
Mobile Programming - 10 FirebaseMobile Programming - 10 Firebase
Mobile Programming - 10 FirebaseAndiNurkholis1
 
Mobile Programming - 9 Profile UI, Navigation Basic and Splash Screen
Mobile Programming - 9 Profile UI, Navigation Basic and Splash ScreenMobile Programming - 9 Profile UI, Navigation Basic and Splash Screen
Mobile Programming - 9 Profile UI, Navigation Basic and Splash ScreenAndiNurkholis1
 
Mobile Programming - 8 Progress Bar, Draggable Music Knob, Timer
Mobile Programming - 8 Progress Bar, Draggable Music Knob, TimerMobile Programming - 8 Progress Bar, Draggable Music Knob, Timer
Mobile Programming - 8 Progress Bar, Draggable Music Knob, TimerAndiNurkholis1
 
Mobile Programming - 7 Side Effects, Effect Handlers, and Simple Animations
Mobile Programming - 7 Side Effects, Effect Handlers, and Simple AnimationsMobile Programming - 7 Side Effects, Effect Handlers, and Simple Animations
Mobile Programming - 7 Side Effects, Effect Handlers, and Simple AnimationsAndiNurkholis1
 
Mobile Programming - 6 Textfields, Button, Showing Snackbars and Lists
Mobile Programming - 6 Textfields, Button, Showing Snackbars and ListsMobile Programming - 6 Textfields, Button, Showing Snackbars and Lists
Mobile Programming - 6 Textfields, Button, Showing Snackbars and ListsAndiNurkholis1
 
Mobile Programming - 5 Stylling Text and State
Mobile Programming - 5 Stylling Text and StateMobile Programming - 5 Stylling Text and State
Mobile Programming - 5 Stylling Text and StateAndiNurkholis1
 
Mobile Programming - 4 Modifiers and Image Card
Mobile Programming - 4 Modifiers and Image CardMobile Programming - 4 Modifiers and Image Card
Mobile Programming - 4 Modifiers and Image CardAndiNurkholis1
 
Mobile Programming - 3 Rows, Column and Basic Sizing
Mobile Programming - 3 Rows, Column and Basic SizingMobile Programming - 3 Rows, Column and Basic Sizing
Mobile Programming - 3 Rows, Column and Basic SizingAndiNurkholis1
 
Algoritma dan Struktur Data (Python) - Struktur Data
Algoritma dan Struktur Data (Python) - Struktur DataAlgoritma dan Struktur Data (Python) - Struktur Data
Algoritma dan Struktur Data (Python) - Struktur DataAndiNurkholis1
 
Mobile Programming - 2 Jetpack Compose
Mobile Programming - 2 Jetpack ComposeMobile Programming - 2 Jetpack Compose
Mobile Programming - 2 Jetpack ComposeAndiNurkholis1
 
Mobile Programming - 1 Introduction
Mobile Programming - 1 IntroductionMobile Programming - 1 Introduction
Mobile Programming - 1 IntroductionAndiNurkholis1
 
Algoritma dan Struktur Data (Python) - Perulangan
Algoritma dan Struktur Data (Python) - PerulanganAlgoritma dan Struktur Data (Python) - Perulangan
Algoritma dan Struktur Data (Python) - PerulanganAndiNurkholis1
 
Algoritma dan Struktur Data (Python) - Percabangan
Algoritma dan Struktur Data (Python) - PercabanganAlgoritma dan Struktur Data (Python) - Percabangan
Algoritma dan Struktur Data (Python) - PercabanganAndiNurkholis1
 
Algoritma dan Struktur Data (Python) - Struktur I/O
Algoritma dan Struktur Data (Python) - Struktur I/OAlgoritma dan Struktur Data (Python) - Struktur I/O
Algoritma dan Struktur Data (Python) - Struktur I/OAndiNurkholis1
 
Algoritma dan Struktur Data (Python) - Notasi Algoritmik
Algoritma dan Struktur Data (Python) - Notasi AlgoritmikAlgoritma dan Struktur Data (Python) - Notasi Algoritmik
Algoritma dan Struktur Data (Python) - Notasi AlgoritmikAndiNurkholis1
 
Algoritma dan Struktur Data (Python) - Pengantar Algoritma
Algoritma dan Struktur Data (Python) - Pengantar AlgoritmaAlgoritma dan Struktur Data (Python) - Pengantar Algoritma
Algoritma dan Struktur Data (Python) - Pengantar AlgoritmaAndiNurkholis1
 
Algorithm and Data Structure - Binary Search
Algorithm and Data Structure - Binary SearchAlgorithm and Data Structure - Binary Search
Algorithm and Data Structure - Binary SearchAndiNurkholis1
 
Algorithm and Data Structure - Linear Search
Algorithm and Data Structure - Linear SearchAlgorithm and Data Structure - Linear Search
Algorithm and Data Structure - Linear SearchAndiNurkholis1
 
Algorithm and Data Structure - Queue
Algorithm and Data Structure - QueueAlgorithm and Data Structure - Queue
Algorithm and Data Structure - QueueAndiNurkholis1
 
Algorithm and Data Structure - Stack
Algorithm and Data Structure - StackAlgorithm and Data Structure - Stack
Algorithm and Data Structure - StackAndiNurkholis1
 

More from AndiNurkholis1 (20)

Mobile Programming - 10 Firebase
Mobile Programming - 10 FirebaseMobile Programming - 10 Firebase
Mobile Programming - 10 Firebase
 
Mobile Programming - 9 Profile UI, Navigation Basic and Splash Screen
Mobile Programming - 9 Profile UI, Navigation Basic and Splash ScreenMobile Programming - 9 Profile UI, Navigation Basic and Splash Screen
Mobile Programming - 9 Profile UI, Navigation Basic and Splash Screen
 
Mobile Programming - 8 Progress Bar, Draggable Music Knob, Timer
Mobile Programming - 8 Progress Bar, Draggable Music Knob, TimerMobile Programming - 8 Progress Bar, Draggable Music Knob, Timer
Mobile Programming - 8 Progress Bar, Draggable Music Knob, Timer
 
Mobile Programming - 7 Side Effects, Effect Handlers, and Simple Animations
Mobile Programming - 7 Side Effects, Effect Handlers, and Simple AnimationsMobile Programming - 7 Side Effects, Effect Handlers, and Simple Animations
Mobile Programming - 7 Side Effects, Effect Handlers, and Simple Animations
 
Mobile Programming - 6 Textfields, Button, Showing Snackbars and Lists
Mobile Programming - 6 Textfields, Button, Showing Snackbars and ListsMobile Programming - 6 Textfields, Button, Showing Snackbars and Lists
Mobile Programming - 6 Textfields, Button, Showing Snackbars and Lists
 
Mobile Programming - 5 Stylling Text and State
Mobile Programming - 5 Stylling Text and StateMobile Programming - 5 Stylling Text and State
Mobile Programming - 5 Stylling Text and State
 
Mobile Programming - 4 Modifiers and Image Card
Mobile Programming - 4 Modifiers and Image CardMobile Programming - 4 Modifiers and Image Card
Mobile Programming - 4 Modifiers and Image Card
 
Mobile Programming - 3 Rows, Column and Basic Sizing
Mobile Programming - 3 Rows, Column and Basic SizingMobile Programming - 3 Rows, Column and Basic Sizing
Mobile Programming - 3 Rows, Column and Basic Sizing
 
Algoritma dan Struktur Data (Python) - Struktur Data
Algoritma dan Struktur Data (Python) - Struktur DataAlgoritma dan Struktur Data (Python) - Struktur Data
Algoritma dan Struktur Data (Python) - Struktur Data
 
Mobile Programming - 2 Jetpack Compose
Mobile Programming - 2 Jetpack ComposeMobile Programming - 2 Jetpack Compose
Mobile Programming - 2 Jetpack Compose
 
Mobile Programming - 1 Introduction
Mobile Programming - 1 IntroductionMobile Programming - 1 Introduction
Mobile Programming - 1 Introduction
 
Algoritma dan Struktur Data (Python) - Perulangan
Algoritma dan Struktur Data (Python) - PerulanganAlgoritma dan Struktur Data (Python) - Perulangan
Algoritma dan Struktur Data (Python) - Perulangan
 
Algoritma dan Struktur Data (Python) - Percabangan
Algoritma dan Struktur Data (Python) - PercabanganAlgoritma dan Struktur Data (Python) - Percabangan
Algoritma dan Struktur Data (Python) - Percabangan
 
Algoritma dan Struktur Data (Python) - Struktur I/O
Algoritma dan Struktur Data (Python) - Struktur I/OAlgoritma dan Struktur Data (Python) - Struktur I/O
Algoritma dan Struktur Data (Python) - Struktur I/O
 
Algoritma dan Struktur Data (Python) - Notasi Algoritmik
Algoritma dan Struktur Data (Python) - Notasi AlgoritmikAlgoritma dan Struktur Data (Python) - Notasi Algoritmik
Algoritma dan Struktur Data (Python) - Notasi Algoritmik
 
Algoritma dan Struktur Data (Python) - Pengantar Algoritma
Algoritma dan Struktur Data (Python) - Pengantar AlgoritmaAlgoritma dan Struktur Data (Python) - Pengantar Algoritma
Algoritma dan Struktur Data (Python) - Pengantar Algoritma
 
Algorithm and Data Structure - Binary Search
Algorithm and Data Structure - Binary SearchAlgorithm and Data Structure - Binary Search
Algorithm and Data Structure - Binary Search
 
Algorithm and Data Structure - Linear Search
Algorithm and Data Structure - Linear SearchAlgorithm and Data Structure - Linear Search
Algorithm and Data Structure - Linear Search
 
Algorithm and Data Structure - Queue
Algorithm and Data Structure - QueueAlgorithm and Data Structure - Queue
Algorithm and Data Structure - Queue
 
Algorithm and Data Structure - Stack
Algorithm and Data Structure - StackAlgorithm and Data Structure - Stack
Algorithm and Data Structure - Stack
 

Recently uploaded

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 

Recently uploaded (20)

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 

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