forked from andrewelkins/Laravel-4-Bootstrap-Starter-Site
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use view composer for comment form andrewelkins#236
- Loading branch information
Showing
8 changed files
with
52 additions
and
30 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php namespace Acme\Composers; | ||
|
||
class CommentComposer { | ||
|
||
public function compose($view) | ||
{ | ||
|
||
$viewData = $view->getData(); | ||
if (!\Auth::check()) { | ||
return $view->nest('commentForm', 'site.partials.comment_auth'); | ||
} | ||
|
||
if (!$viewData['canComment']) { | ||
return $view->nest('commentForm', 'site.partials.comment_perm'); | ||
} | ||
|
||
return $view->nest('commentForm', 'site.partials.comment_form', $viewData); | ||
} | ||
|
||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
|
||
View::composer('site/blog/view_post', 'Acme\Composers\CommentComposer'); |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
You need to be logged in to add comments.<br /><br /> | ||
Click <a href="{{{ URL::to('user/login') }}}">here</a> to login into your account. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<h4>Add a Comment</h4> | ||
<form method="post" action="{{{ URL::to($post->url()) }}}"> | ||
<input type="hidden" name="_token" value="{{{ Session::getToken() }}}" /> | ||
|
||
<textarea class="col-md-12 input-block-level" rows="4" name="comment" id="comment">{{{ Request::old('comment') }}}</textarea> | ||
|
||
<div class="form-group"> | ||
<div class="col-md-12"> | ||
<input type="submit" class="btn btn-default" id="submit" value="Submit" /> | ||
</div> | ||
</div> | ||
</form> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
You don't have the correct permissions to add comments. |
This file contains 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