This commit is contained in:
ludo
2025-02-15 12:12:42 +01:00
parent d1cc62c9b1
commit 592402a6c1
53 changed files with 1098 additions and 404 deletions

View File

@@ -3,28 +3,22 @@
namespace App\Repositories\Core;
use App\Datatables\Admin\Core\CommentsDataTable;
use App\Models\Core\Comment as rawComment;
use App\Models\Core\Comment;
use App\Repositories\Core\Auth\Users;
use App\Traits\Model\Basic;
class Comments
{
public static function get($id)
{
return rawComment::find($id);
}
use Basic;
public static function getDatatable()
{
$model = new CommentsDataTable();
return $model->html();
return (new CommentsDataTable())->html();
}
public static function getCommentsByModel($model, $model_id)
{
$class = self::getClass($model);
return self::getCommentsByClass($class, $model_id);
return self::getCommentsByClass(self::getClass($model), $model_id);
}
public static function getCommentsByClass($class, $id)
@@ -32,14 +26,14 @@ class Comments
return self::getByModel(self::getModel($class, $id));
}
public static function getModel($class, $id)
public static function getItem($class, $id)
{
return $class::find($id);
}
public static function getClass($model)
{
return 'App\Models\\'.str_replace('.', '\\', $model);
return 'App\Models\\' . str_replace('.', '\\', $model);
}
public static function getByModel($model)
@@ -75,25 +69,11 @@ class Comments
$data['is_approved'] = true;
$data['user_id'] = Users::getId();
return rawComment::create($data);
return Comment::create($data);
}
public static function update($data, $id = false)
public static function getModel()
{
$id = $id ? $id : $data['id'];
$model = self::get($id);
$model->update($data);
return $model;
}
public static function deleteComments($model)
{
return true;
}
public static function deleteComment($model, $index)
{
return true;
return Comment::query();
}
}