Skip to content

Instantly share code, notes, and snippets.

@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>
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')
<h1>{{ ucfirst($question->user->username) }} asks:</h1>
<p>
{{ e($question->question) }}
</p>
@endsection
public static function your_questions() {
return static::where('user_id','=',Auth::user()->id)->paginate(3);
}
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());
}
@layout('layouts.default')
@section('content')
<h1>{{ ucfirst($username) }} Questions</h1>
@if(!$questions->results)
<p>You've not posted any questions yet.</p>
@else
<ul>
@foreach($questions->results as $question)
@layout('layouts.default')
@section('content')
<h1>{{ ucfirst($username) }} Questions</h1>
@if(!$questions->results)
<p>You've not posted any questions yet.</p>
@else
<ul>
@foreach($questions->results as $question)
// Nossa ação de editar também deve ser protegida!
public function __construct() {
$this->filter('before', 'auth')->only(array('create', 'your_questions', 'edit'));
}
public function get_edit($id = NULL) {
if (!$this->question_belongs_to_user($id)) {
return Redirect::to_route('your_questions')->with('message', 'Invalid Question');
}
@layout("layouts.default")
@section('content')
<h1>Edit Your Question</h1>
@if($errors->has())
<ul id="form-errors">
{{ $errors->first('question', '<li>:message</li>') }}
{{ $errors->first('solved', '<li>:message</li>') }}
</ul>