Fix on preview mode
This commit is contained in:
@@ -22,6 +22,12 @@ class Comments
|
||||
return $model->html();
|
||||
}
|
||||
|
||||
public static function getCommentsByModel($model, $model_id)
|
||||
{
|
||||
$class = self::getClass($model);
|
||||
return self::getCommentsByClass($class, $model_id);
|
||||
}
|
||||
|
||||
public static function getCommentsByClass($class, $id)
|
||||
{
|
||||
return self::getByModel(self::getModel($class, $id));
|
||||
@@ -29,17 +35,17 @@ class Comments
|
||||
|
||||
public static function getModel($class, $id)
|
||||
{
|
||||
return $$class::find($id);
|
||||
return $class::find($id);
|
||||
}
|
||||
|
||||
public static function getClass($class)
|
||||
public static function getClass($model)
|
||||
{
|
||||
return 'App\Models\\' . str_replace('.','\\', $class);
|
||||
return 'App\Models\\' . str_replace('.','\\', $model);
|
||||
}
|
||||
|
||||
public static function getByModel($model)
|
||||
{
|
||||
return $model ? $model->comments : false;
|
||||
return $model ? $model->comments->sortByDesc('updated_at')->toArray() : false;
|
||||
}
|
||||
|
||||
public static function storeComments($model, $comments)
|
||||
|
||||
Reference in New Issue
Block a user