Laravel Databases

Easy data management.

 

  • Multiple connections
  • Eloquent ORM
  • Migrations and seeding tools

Connection Options

config/database.php

 

  • MySQL
  • Postgres
  • SQLite
  • SQL Server

Database GUI

View data quickly and easily.

 

  • All: Navicat
  • Mac: Sequel Pro
  • Windows: HeidiSQL
  • Linux: SQuirreL SQL

Eloquent ORM

  • Object relational mapping
  • Built on PHP ActiveRecord

Database Table <-> "Model"

User Model

app/User.php

$query = "SELECT * FROM users where id = '1'";
$result = mysql_query($query);
$user = User::find(1);

Seeding

Inserting data into our database.

Model Factory: Easy way to generate fake data

Blade Templating

  • layouts
  • pages
  • partials

Extending Layouts


@extend('layouts.main')

Extending Layouts


@yield('content')
@section('content')
    the content goes here
@endsection

Including Child Views


@include('partials.header')

Echo Comparison

// normal php data
<?php echo $username ?>
// with blade tags
{{ $username }}

Stacks

@stack('scripts')
@push('scripts')
    <script src="js/dashboard.js"></script>
@endpush

Laravel Databases

By Chris Sevilleja

Laravel Databases

  • 393
Loading comments...

More from Chris Sevilleja