add shipping rules
This commit is contained in:
@@ -2,15 +2,12 @@
|
||||
|
||||
namespace App\Repositories\Core;
|
||||
|
||||
use BeyondCode\Comments\Comment;
|
||||
use App\Datatables\Admin\Core\CommentsDataTable;
|
||||
use App\Models\Core\Comment as rawComment;
|
||||
use App\Repositories\Core\Auth\Users;
|
||||
|
||||
use App\Datatables\Admin\Core\CommentsDataTable;
|
||||
|
||||
class Comments
|
||||
{
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return rawComment::find($id);
|
||||
@@ -19,12 +16,14 @@ class Comments
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = new CommentsDataTable();
|
||||
|
||||
return $model->html();
|
||||
}
|
||||
|
||||
public static function getCommentsByModel($model, $model_id)
|
||||
{
|
||||
$class = self::getClass($model);
|
||||
|
||||
return self::getCommentsByClass($class, $model_id);
|
||||
}
|
||||
|
||||
@@ -40,14 +39,14 @@ class Comments
|
||||
|
||||
public static function getClass($model)
|
||||
{
|
||||
return 'App\Models\\' . str_replace('.', '\\', $model);
|
||||
return 'App\Models\\'.str_replace('.', '\\', $model);
|
||||
}
|
||||
|
||||
|
||||
public static function getByModel($model)
|
||||
{
|
||||
return $model ? $model->comments->sortByDesc('updated_at')->toArray() : false;
|
||||
}
|
||||
|
||||
|
||||
public static function storeComments($model, $comments)
|
||||
{
|
||||
foreach (($comments ?? []) as $comment) {
|
||||
@@ -66,6 +65,7 @@ class Comments
|
||||
unset($data['_token']);
|
||||
$data['commentable_type'] = Comments::getClass($data['commentable_type']);
|
||||
$data['commentable_id'] = (int) $data['commentable_id'];
|
||||
|
||||
return $id ? self::update($data, $id) : self::create($data);
|
||||
}
|
||||
|
||||
@@ -74,6 +74,7 @@ class Comments
|
||||
unset($data['id']);
|
||||
$data['is_approved'] = true;
|
||||
$data['user_id'] = Users::getId();
|
||||
|
||||
return rawComment::create($data);
|
||||
}
|
||||
|
||||
@@ -82,6 +83,7 @@ class Comments
|
||||
$id = $id ? $id : $data['id'];
|
||||
$model = self::get($id);
|
||||
$model->update($data);
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user