Schema::create('posts', function($table)
{
$table->increments('id');
$table->string('title');
$table->string('tagline', 64); // constraint as second argument
$table->text('body');
$table->integer('category_id')
->unsigned() // chain methods for other options
->nullable(); // for optional fields
$table->softDeletes();
$table->timestamps();
});
function comments()
{
return $this->hasMany('Comment');
}
function friends()
{
return $this->belongsToMany('User');
}
<a href="<?php echo $post->link; ?>">
<?php echo $post->title; ?>
</a>
<a href="{{ $post->link }}">
{{ $post->title }}
</a>
@if( $a > 3 )
{{ $a }} @endif
@section('scripts')
<script>alert('woop');</script>
@stop
@yield('scripts')
Route::get('/posts/{post}', function($post)
{
return "Post title: $post!";
});
Route::bind('post-slug', function($slug) {
return Post::where('slug', $slug)
->firstOrFail();
})
Route::model('post', 'Post');
Route::get('posts/{post-slug}', function($post) {
return View::make('blog.post')
->with('post', $post);
});
Route::group(['prefix' => 'post'], function() {
Route::get('{post-slug}', function($post) { return 'the post'; });
Route::get('{post-slug}/edit', function($post) { return 'edit post'; });
Route::post('{post-slug}/edit', function($post) {
// Validate
// Save
return Redirect::route('blog.post');
});
});
Route::get('posts', ['as' => 'posts.list', function()
{
return 'list of posts';
}]);
Redirect::route('posts.list);
URL::route('posts.list');
URL::route('posts.show', ['post-slug' => $post->slug]);
Route::get('home', ['as' => 'home', 'uses' => 'SiteController@index']);
Route::controller('/', 'SiteController');
/* In SiteController.php */
public function getIndex() { return ''; }
public function postIndex() { return ''; }
Route::resource('post', 'PostController');
Route::group(['prefix' => 'admin', 'before' => 'auth|is:admin'], function() {
Route::get('', function() { return ''; })
});
Route::filter('is', function($level)
{
if ( ! Auth::user()->is($level) )
{
return Redirect::route('home');
}
});
$this->info('You did something');
$this->error('Shit gone crazy');
$this->output('<fg="green">foo</fg="green" ');
$style = new OutputFormatterStyle('red', 'yellow', array('bold', 'blink'));
$this->output->getFormatter()->setStyle('fire', $style);
$this->output->writeln('<fire>foo</fire>');
$this->load->helper('url');
site_url(array('blog', 'posts', $post->slug));
Uri::create("blog/posts/{$post->slug}");
URL::to('blog/posts/new-post);
URL::route('blog.post', ['slug' => $post->slug]);
Config::get();
$this->config &= Config::getInstance()