-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e7614ec
commit f4bbf1e
Showing
14 changed files
with
351 additions
and
17 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
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
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 App; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Post_Comment extends Model | ||
{ | ||
protected $table = 'post_comments'; | ||
|
||
public function post() | ||
{ | ||
return $this->belongsTo('App\Post', 'post_id'); | ||
} | ||
|
||
public function author() | ||
{ | ||
return $this->belongsTo('App\User', 'user_id'); | ||
} | ||
} |
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
35 changes: 35 additions & 0 deletions
35
database/migrations/2016_06_24_162123_create_post_comments.php
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,35 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
class CreatePostComments extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('post_comments', function (Blueprint $table) { | ||
$table->increments('id'); | ||
$table->integer('user_id')->nullable(); | ||
$table->integer('post_id'); | ||
$table->string('name')->nullable(); | ||
$table->string('email')->nullable(); | ||
$table->text('content'); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::drop('post_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
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,60 @@ | ||
@extends('layouts.admin.index') | ||
@section('title', $post->title . " Comments") | ||
@section('content') | ||
<a href="{{ url('admin/blogs', [$post->blog->id]) }}" class="btn btn-primary" role="button">Back</a><br><br> | ||
<div class="row"> | ||
<div class="col-sm-12 col-md-6 col-md-offset-3"> | ||
<center> | ||
<h3> | ||
{{ $post->title }} Comments | ||
</h3> | ||
</center> | ||
<br> | ||
@if(count($comments) == 0) | ||
<center> | ||
This post have no comments yet. | ||
</center> | ||
@endif | ||
@foreach($comments as $comment) | ||
<div class="panel panel-default"> | ||
<div class="panel-body"> | ||
@if($comment->user_id) | ||
<div class="row"> | ||
<div class="col-sm-6 col-md-2"> | ||
<?php $grav_url = "https://www.gravatar.com/avatar/".md5(strtolower(trim($comment->author->email)))."?s=75";?> | ||
<center> | ||
<img height="75" width="75" class="img-responsive img-circle" src="{!! $grav_url !!}"> | ||
</center> | ||
</div> | ||
<div class="col-sm-6 col-md-10"> | ||
<span class="comment-author">{{ $comment->author->name }}</span> | ||
<span class="pull-right">{{ date("F jS, Y",strtotime($comment->created_at)) }}</span> | ||
<br> | ||
<i>{{ $comment->author->email }}</i> | ||
</div> | ||
</div> | ||
@else | ||
<div class="row"> | ||
<div class="col-sm-6 col-md-2"> | ||
<center> | ||
<img height="75" width="75" class="img-responsive img-circle" src="{{ url('admin_panel/img/avatar.jpg') }}"> | ||
</center> | ||
</div> | ||
<div class="col-sm-6 col-md-10"> | ||
<span class="comment-author">{{ $comment->name }}</span> | ||
<span class="pull-right">{{ date("F jS, Y",strtotime($comment->created_at)) }}</span> | ||
<br> | ||
<i>{{ $comment->email }}</i> | ||
</div> | ||
</div> | ||
@endif | ||
<br> | ||
<span class="comment-content"> | ||
{{ $comment->content }} | ||
</span> | ||
</div> | ||
</div> | ||
@endforeach | ||
</div> | ||
</div> | ||
@endsection |
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
Oops, something went wrong.