-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #91 from balajidharma/2.x-Changes
Added comment and forum thread
- Loading branch information
Showing
20 changed files
with
638 additions
and
52 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 |
---|---|---|
|
@@ -15,3 +15,7 @@ npm-debug.log | |
yarn-error.log | ||
/.idea | ||
/.vscode | ||
|
||
**/caddy | ||
frankenphp | ||
frankenphp-worker.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
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,148 @@ | ||
<?php | ||
|
||
namespace App\Grid\Admin; | ||
|
||
use BalajiDharma\LaravelComment\Models\Comment; | ||
use BalajiDharma\LaravelCrud\CrudBuilder; | ||
use Config; | ||
|
||
class CommentGrid extends CrudBuilder | ||
{ | ||
public $title = 'Comments'; | ||
|
||
public $description = 'Manage Comments'; | ||
|
||
public $model = Comment::class; | ||
|
||
public $route = 'admin.comment'; | ||
|
||
public function columns() | ||
{ | ||
return [ | ||
[ | ||
'attribute' => 'id', | ||
'label' => __('ID'), | ||
'sortable' => true, | ||
'searchable' => true, | ||
'list' => [ | ||
'class' => 'BalajiDharma\LaravelCrud\Column\LinkColumn', | ||
'route' => 'admin.comment.show', | ||
'route_params' => ['comment' => 'id'], | ||
'attr' => ['class' => 'link link-primary'], | ||
], | ||
], | ||
[ | ||
'attribute' => 'content', | ||
'label' => __('Content'), | ||
'searchable' => true, | ||
'list' => [ | ||
'class' => 'BalajiDharma\LaravelCrud\Column\LinkColumn', | ||
'route' => 'admin.comment.show', | ||
'route_params' => ['comment' => 'id'], | ||
'attr' => ['class' => 'link link-primary'], | ||
], | ||
'form_options' => function ($model) { | ||
return [ | ||
'field_type' => 'textarea', | ||
'attr' => [ | ||
'rows' => 5 | ||
] | ||
]; | ||
}, | ||
], | ||
[ | ||
'attribute' => 'commenter_type', | ||
'label' => __('Commenter Type'), | ||
'type' => 'select', | ||
'list' => true, | ||
'show' => true, | ||
'form_options' => function ($model) { | ||
$commenter_type = [ | ||
'App\Models\User' => __('User'), | ||
]; | ||
|
||
return [ | ||
'choices' => $commenter_type, | ||
'empty_value' => __('Select an option'), | ||
'default_value' => $model ? $model->commenter_type : null, | ||
]; | ||
}, | ||
], | ||
[ | ||
'attribute' => 'commenter_id', | ||
'label' => __('Commenter ID'), | ||
'list' => false, | ||
'show' => false, | ||
], | ||
[ | ||
'attribute' => 'commenter', | ||
'label' => __('Commenter'), | ||
'value' => function ($model) { | ||
return $model->commenter ? $model->commenter->name : null; | ||
}, | ||
'create' => false, | ||
'edit' => false, | ||
'sortable' => true, | ||
], | ||
[ | ||
'attribute' => 'commentable_type', | ||
'label' => __('Commentable Type'), | ||
'type' => 'select', | ||
'list' => false, | ||
'form_options' => function ($model) { | ||
$commentable_type = [ | ||
'Balajidharma\LaravelForum\Models\Thread' => __('Thread'), | ||
]; | ||
|
||
return [ | ||
'choices' => $commentable_type, | ||
'empty_value' => __('Select an option'), | ||
'default_value' => $model ? $model->commentable_type : null, | ||
]; | ||
}, | ||
], | ||
[ | ||
'attribute' => 'commentable_id', | ||
'label' => __('Commentable ID'), | ||
'list' => false, | ||
], | ||
[ | ||
'attribute' => 'parent_id', | ||
'label' => __('Parent ID'), | ||
'list' => false, | ||
'form_options' => function ($model) { | ||
return [ | ||
'field_type' => 'text', | ||
]; | ||
}, | ||
], | ||
[ | ||
'attribute' => 'status', | ||
'label' => __('Status'), | ||
'type' => 'select', | ||
'value' => function ($model) { | ||
return __(array_flip(config('comment.status'))[$model->status]); | ||
}, | ||
'form_options' => function ($model) { | ||
$status = []; | ||
foreach (config('comment.status') as $key => $value) { | ||
$status[$value] = __($key); | ||
}; | ||
|
||
return [ | ||
'choices' => $status, | ||
'default_value' => $model ? $model->status : null, | ||
]; | ||
}, | ||
], | ||
[ | ||
'attribute' => 'created_at', | ||
'sortable' => true, | ||
], | ||
[ | ||
'attribute' => 'updated_at', | ||
'sortable' => true, | ||
], | ||
]; | ||
} | ||
} |
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,43 @@ | ||
<?php | ||
|
||
namespace App\Grid\Admin; | ||
|
||
use BalajiDharma\LaravelCategory\Models\CategoryType; | ||
|
||
class GridHelper | ||
{ | ||
public static function getTagsField($attribute, $tagName) | ||
{ | ||
return [ | ||
'attribute' => $attribute, | ||
'label' => __('Tags'), | ||
'list' => false, | ||
'fillable' => true, | ||
'value' => function ($model) use ($tagName) { | ||
return collect($model->getCategoriesByType($tagName)->get())->pluck('name')->implode(', '); | ||
}, | ||
'form_options' => function ($model) use ($attribute, $tagName) { | ||
if (old($attribute)) { | ||
if (json_decode(old($attribute))) { | ||
$value = collect(json_decode(old($attribute)))->pluck('value')->implode(','); | ||
} else { | ||
$value = old($attribute); | ||
} | ||
} else { | ||
$value = $model ? collect($model->getCategoriesByType($tagName)->get())->pluck('name')->implode(', ') : ''; | ||
} | ||
|
||
return [ | ||
'field_type' => 'text', | ||
'value' => $value, | ||
'attr' => [ | ||
'data-tagify' => 1, | ||
'placeholder' => 'Enter tag', | ||
'data-tagify-maxTags' => 5, | ||
'data-tagify-url' => route('admin.category.type.item.index', CategoryType::where('machine_name', $tagName)->first()->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
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
Oops, something went wrong.