Laravel Blog
Laravel Blog
//views/admin/_layouts/admin.blade.php
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>My Awesome Admin Panel</title>
{{ HTML::style('css/admin.css') }}
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<header>
<div class="container">
<h1>My Awesome Admin Panel</h1>
</div>
</header>
<main class="container">
@yield('content')
</main>
<footer>
<div class="container">
© {{ date('Y') }} My Awesome Company
</div>
</footer>
</body>
</html>
public/css/admin.css
* { font-size: 14px; font-family: helvetica, arial, sans-serif; }
body { margin: 0; padding: 0; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
header { padding: 20px 0; background: #eee; margin-bottom: 20px; }
main { margin-bottom: 20px; }
footer { border-top: 1px solid #ccc; margin: 40px 0; padding-top: 20px; text-align:
right; }
.container { max-width: 700px; margin: 0 auto; width: 96%; padding: 0 2%; }
/* forms */
form { width: 94%; padding: 3%; border: 1px solid #ddd; border-radius: 5px; }
form li { list-style-type: none; padding-bottom: 20px; }
form li .error { display: inline-block; color: red; }
form label { display: block; font-weight: bold; }
input[type="text"], input[type="email"], input[type="password"], textarea { border:
1px solid #ccc; border-radius: 3px; width: 96%; font-size: 14px; }
input[type="text"], input[type="email"], input[type="password"] { height: 30px;
line-height: 30px; padding: 0 2%; }
textarea { width: 96%; padding: 2%; }
input[type="submit"] { background: #4288CE; color: #fff; height: 40px; line-height:
40px; border: none; border-radius: 3px; padding: 0 20px; -webkit-transition: all
0.5s ease-in-out; -moz-transition: all 0.5s ease-in-out; -o-transition: all 0.5s
ease-in-out; transition: all 0.5s ease-in-out; }
input[type="submit"]:hover { background: #333; }
form.destroy { display: inline-block; padding: 0; border: none; width: auto; }
form.destroy input[type="submit"] { margin-left: 10px; background: #999; display:
inline-block; height: auto; padding: 0.2em; line-height: 1.2em; }
form.destroy input[type="submit"]:hover { background: red; }
admin/post/index.blade.php
@extends('admin._layouts.admin')
@section('content')
<h1>Posts</h1>
{{ link_to_route('admin.posts.create', 'Create new Post') }}
@if(count($posts))
<ul>
@foreach($posts as $post)
<li>
{{ link_to_route('admin.posts.edit', $post->title, array($post->id)) }}
{{ Form::open(array('route' => array('admin.posts.destroy', $post->id),
'method' => 'delete', 'class' => 'destroy')) }}
{{ Form::submit('Delete') }}
{{ Form::close() }}
</li>
@endforeach
</ul>
@endif
@stop
admin/posts/edit.blade.php
@extends('admin._layouts.admin')
@section('content')
<h1>Edit Post</h1>
{{ Form::model($post, array('route' => array('admin.posts.update', $post->id),
'method' => 'put')) }}
@include('admin.posts._partials.form')
{{ Form::close() }}
@stop
views/admin/posts/create.blade.php
@extends('admin._layouts.admin')
@section('content')
<h1>Create Post</h1>
{{ Form::open(array('route' => 'admin.posts.store')) }}
@include('admin.posts._partials.form')
{{ Form::close() }}
@stop
views/admin/posts/_partials/form.blade.php
<ul>
<li>
{{ Form::label('user_id', 'Author') }}
{{ Form::select('user_id', User::lists('name', 'id')) }}
{{ $errors->first('user_id', '<p class="error">:message</p>') }}
</li>
<li>
{{ Form::label('title', 'Title') }}
{{ Form::text('title') }}
{{ $errors->first('title', '<p class="error">:message</p>') }}
</li>
<li>
{{ Form::label('body', 'Body') }}
{{ Form::textarea('body') }}
{{ $errors->first('body', '<p class="error">:message</p>') }}
</li>
<li>
{{ Form::submit('Save') }}
</li>
</ul>
routes/web.php