Postingan lainnya
laravel 5.3 dasar bagian database
mohon pencerahannya gan,, lagi belajar & ngikutin video Laravel 5.3 dasar bagian Database dengan Query Builder,, ada eror kayak gini: <a href=' http://imgur.com/1TCNbbH '> http://imgur.com/1TCNbbH </a>
kode BlogController.php:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
//use Illuminate\Support\Facades\DB;
use DB;
use App\Http\Requests;
class BlogController extends Controller
{
public function index()
{
return view('blog/halo');
}
public function show($id)
{
$nilai = 'Ini adalah halaman ' . $id;
$users = DB::table('users')->get();
$unescaped = '<script> alert("x!") </script>';
return view('blog/single', ['blog' => $nilai , 'users' => $users, 'unescaped' => $unescaped]);
}
}
single.blade.php:
@extends('layouts.master')
@section('title', 'Blog Wah')
@section('content')
<h1>Selamat Datang Di Blog Ieu</h1>
<h2> {{ $blog }} !! </h2>
@foreach($users as $user)
<li> {{ $user->username }} </li>
@endforeach
{{ $unescaped }}
@if(count($users) > 5)
<p> usernya lebih dari lima </p>
@else
<p> usernya tidak lebih dari lima </p>
@endif
@endsection
0