forked from eatvio/eatvio-infra
analysators added
This commit is contained in:
@@ -2,15 +2,14 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\PlanLike;
|
||||
use App\Presenters\PlanPresenter;
|
||||
use CyrildeWit\EloquentViewable\Contracts\Viewable;
|
||||
use CyrildeWit\EloquentViewable\InteractsWithViews;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Laracasts\Presenter\PresentableTrait;
|
||||
|
||||
class Plan extends Model implements Viewable
|
||||
@@ -21,7 +20,7 @@ class Plan extends Model implements Viewable
|
||||
|
||||
protected $withCount = [
|
||||
'likes',
|
||||
'comments'
|
||||
'comments',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
@@ -61,11 +60,11 @@ class Plan extends Model implements Viewable
|
||||
{
|
||||
$result = [];
|
||||
for ($i = 1; $i <= $this->packets_count; $i++) {
|
||||
$key = 'packet' . $i . '_options';
|
||||
$key = 'packet'.$i.'_options';
|
||||
|
||||
// $data = $this->unserializeOptionsObj($this->$key);
|
||||
$data = $this->$key;
|
||||
if (!is_null($data)) {
|
||||
if (! is_null($data)) {
|
||||
$result = array_merge($result, data_get($data, 'items', []));
|
||||
}
|
||||
}
|
||||
@@ -79,7 +78,7 @@ class Plan extends Model implements Viewable
|
||||
$data = $this->type;
|
||||
|
||||
return new Attribute(
|
||||
get: fn() => array_keys($data),
|
||||
get: fn () => array_keys($data),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -87,18 +86,18 @@ class Plan extends Model implements Viewable
|
||||
{
|
||||
$result = 0;
|
||||
for ($i = 1; $i <= $this->packets_count; $i++) {
|
||||
$key = 'packet' . $i . '_options';
|
||||
$key = 'packet'.$i.'_options';
|
||||
// dd($this->$key);
|
||||
// $data = $this->unserializeOptionsObj($this->$key);
|
||||
$data = $this->$key;
|
||||
if (!is_null($data)) {
|
||||
if (! is_null($data)) {
|
||||
$curPrice = (int) data_get($data, 'price', 0);
|
||||
$result = $curPrice > $result ? $curPrice : $result;
|
||||
}
|
||||
}
|
||||
|
||||
return new Attribute(
|
||||
get: fn() => $result,
|
||||
get: fn () => $result,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -116,6 +115,7 @@ class Plan extends Model implements Viewable
|
||||
if (preg_match('/^".*"$/', $str)) {
|
||||
return json_decode(stripslashes(mb_substr($str, 1, -1)));
|
||||
}
|
||||
|
||||
return json_decode(stripslashes($str));
|
||||
}
|
||||
|
||||
@@ -124,6 +124,7 @@ class Plan extends Model implements Viewable
|
||||
if (preg_match('/^".*"$/', $str)) {
|
||||
return json_decode(stripslashes(mb_substr($str, 1, -1)), true);
|
||||
}
|
||||
|
||||
return json_decode(stripslashes($str), true);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user