Skip to content

Instantly share code, notes, and snippets.

public function get_your_questions() {
return View::make('questions.your_questions')
->with('title', 'Make It Snappy Q&A - Your Questions')
->with('username', Auth::user()->username)
->with('questions', Question::your_questions());
}
public static function your_questions() {
return static::where('user_id','=',Auth::user()->id)->paginate(3);
}
@layout('layouts.default')
@section('content')
<h1>{{ ucfirst($question->user->username) }} asks:</h1>
<p>
{{ e($question->question) }}
</p>
@endsection
public function get_view($id = null) {
return View::make('questions.view')
->with('title', 'Make It Snappy - View Question')
->with('question', Question::find($id));
}
@layout('layouts.default')
@section('content')
<div id="ask">
<h1>Ask a Question</h1>
@if(Auth::check())
@if($errors->has())
<p>The following errors have occurred:</p>
@layout('layouts.default')
@section('content')
<div id="ask">
<h1>Ask a Question</h1>
@if(Auth::check())
@if($errors->has())
<p>The following errors have occurred:</p>
// no nosso controller questions.php
public function get_index() {
return View::make('questions.index')
->with('title', 'Make It Snappy Q&A - Home')
->with('questions', Question::unsolved()); // pega as questions no banco de dados
}
// No model question.php
public static function unsolved() {
return static::where('solved','=',0)->order_by('id', 'DESC')->paginate(3);
}
<?php
class Questions_Controller extends Base_Controller {
public $restful = true;
public function __construct() {
$this->filter('before', 'auth')->only(array('create'));
}
@layout('layouts.default')
@section('content')
<div id="ask">
<h1>Ask a Question</h1>
@if(Auth::check())
@if($errors->has())
<p>The following errors have occurred:</p>