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
@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> |
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
@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> |
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
public function get_view($id = null) { | |
return View::make('questions.view') | |
->with('title', 'Make It Snappy - View Question') | |
->with('question', Question::find($id)); | |
} |
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
@layout('layouts.default') | |
@section('content') | |
<h1>{{ ucfirst($question->user->username) }} asks:</h1> | |
<p> | |
{{ e($question->question) }} | |
</p> | |
@endsection |
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
public static function your_questions() { | |
return static::where('user_id','=',Auth::user()->id)->paginate(3); | |
} |
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
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()); | |
} |
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
@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) |
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
@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) |
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
// 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'); | |
} |
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
@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> |