Skip to content

Instantly share code, notes, and snippets.

View Rokt33r's full-sized avatar
🧨
BOOM!

Junyoung Choi Rokt33r

🧨
BOOM!
View GitHub Profile
@Rokt33r
Rokt33r / PostController.php
Last active August 29, 2015 13:58
Laravel 基礎 Lesson 7 - Model(Eloquent) (app/controllers/PostController.php)
<?php
class PostController extends BaseController{
function create(){
return View::make('posts.create');
}
function store(){
Post::create(Input::all());
return Redirect::to('posts');
}
@Rokt33r
Rokt33r / Post.php
Created April 3, 2014 08:37
Laravel 基礎 Lesson 7 - Model(Eloquent) (app/models/Post.php)
<?php
class Post extends Eloquent{
protected $table = 'posts';
protected $fillable = ['title', 'body'];
public $timestamps = false;
}
@Rokt33r
Rokt33r / show.blade.php
Created March 31, 2014 06:31
Laravel 基礎 Lesson 6 - RESTful (app/views/posts/show.blade.php)
@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'])}}
@Rokt33r
Rokt33r / edit.blade.php
Created March 31, 2014 06:30
Laravel 基礎 Lesson 6 - RESTful (app/views/posts/edit.blade.php)
@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>
@Rokt33r
Rokt33r / PostController.php
Created March 31, 2014 06:29
Laravel 基礎 Lesson 6 - RESTful (app/controllers/PostController.php)
<?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')
@Rokt33r
Rokt33r / routes.php
Created March 31, 2014 06:28
Laravel 基礎 Lesson 6 - RESTful (app/routes.php)
<?php
Route::get('/', function()
{
return View::make('hello');
});
Route::resource('posts', 'PostController');
@Rokt33r
Rokt33r / master.blade.php
Created March 29, 2014 19:56
Laravel 基礎 Lesson 5 - Blade & Helper (app/views/layouts/master.blade.php)
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>
@yield('title')
</title>
</head>
<body>
@yield('body')
@Rokt33r
Rokt33r / show.blade.php
Created March 29, 2014 19:55
Laravel 基礎 Lesson 5 - Blade & Helper (app/views/posts/show.blade.php)
@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')}}
@Rokt33r
Rokt33r / create.blade.php
Created March 29, 2014 19:54
Laravel 基礎 Lesson 5 - Blade & Helper (app/views/posts/create.blade.php)
@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>
@Rokt33r
Rokt33r / index.blade.php
Last active August 29, 2015 13:57
Laravel 基礎 Lesson 5 - Blade & Helper (app/views/posts/index.blade.php)
@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)