This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class PostController extends BaseController{ | |
function create(){ | |
return View::make('posts.create'); | |
} | |
function store(){ | |
Post::create(Input::all()); | |
return Redirect::to('posts'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Post extends Eloquent{ | |
protected $table = 'posts'; | |
protected $fillable = ['title', 'body']; | |
public $timestamps = false; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@extends('layouts.master') | |
@section('title') | |
{{$post->title}} - mylaravel | |
@stop | |
@section('body') | |
<h1>{{$post->title}}</h1> | |
<p>{{$post->body}}</p> | |
{{Form::open(['route'=>['posts.destroy',$post->id],'method'=>'DELETE'])}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@extends('layouts.master') | |
@section('title') | |
Edit {{$post->title}} - mylaravel | |
@stop | |
@section('body') | |
{{Form::open(['route'=>['posts.update',$post->id],'method'=>'PUT'])}} | |
{{Form::label('title', 'Title')}}<br> | |
{{Form::text('title', $post->title)}}<br> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class PostController extends BaseController{ | |
function create(){ | |
return View::make('posts.create'); | |
} | |
function store(){ | |
DB::table('posts')->insert([ | |
'title'=>Input::get('title'), | |
'body'=>Input::get('body') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Route::get('/', function() | |
{ | |
return View::make('hello'); | |
}); | |
Route::resource('posts', 'PostController'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title> | |
@yield('title') | |
</title> | |
</head> | |
<body> | |
@yield('body') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@extends('layouts.master') | |
@section('title') | |
{{$post->title}} - mylaravel | |
@stop | |
@section('body') | |
<h1>{{$post->title}}</h1> | |
<p>{{$post->body}}</p> | |
{{link_to('posts', 'Back to list')}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@extends('layouts.master') | |
@section('title') | |
Create a new post - mylaravel | |
@stop | |
@section('body') | |
{{Form::open(['url'=>'posts','method'=>'post'])}} | |
{{Form::label('title', 'Title')}}<br> | |
{{Form::text('title')}}<br> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@extends('layouts.master') | |
@section('title') | |
Posts list - mylaravel | |
@stop | |
@section('body') | |
<h1>Posts list {{link_to('posts/create','create a new post'))}}</h1> | |
<ul> | |
@foreach($posts as $post) |