fix on customer auth, fix filters on shelves, refactor for article_nature, add slug
This commit is contained in:
@@ -82,30 +82,37 @@ trait Basic
|
||||
return self::get($id)->toArray();
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
public static function store($data, $stopStamping = false)
|
||||
{
|
||||
return $data['id'] ?? false ? self::update($data) : self::create($data);
|
||||
return $data['id'] ?? false ? self::update($data, false, $stopStamping) : self::create($data, $stopStamping);
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
public static function create($data, $stopStamping = false)
|
||||
{
|
||||
return self::getModel()->create($data);
|
||||
return self::getModel($stopStamping)->create($data);
|
||||
}
|
||||
|
||||
public static function update($data, $id = false)
|
||||
public static function update($data, $id = false, $stopStamping = false)
|
||||
{
|
||||
$id = $id ? $id : $data['id'];
|
||||
$model = self::get($id);
|
||||
if ($stopStamping) {
|
||||
$model->stopUserstamping();
|
||||
}
|
||||
$model->update($data);
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
public static function destroy($id, $force = false)
|
||||
{
|
||||
$model = self::get($id);
|
||||
|
||||
return $model ? $model->delete() : false;
|
||||
if ($model) {
|
||||
return $force ? $model->forceDelete() : $model->delete();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function count()
|
||||
@@ -125,20 +132,39 @@ trait Basic
|
||||
return $model ? $model->delete() : false;
|
||||
}
|
||||
|
||||
public static function get($id, $relations = false, $relationscount = false)
|
||||
public static function getArray($id, $relations = false, $relationsCount = false)
|
||||
{
|
||||
return self::getModelRelations($relations, $relationscount)->find($id);
|
||||
$model = self::get($id, $relations, $relationsCount);
|
||||
|
||||
return $model ? $model->toArray() : false;
|
||||
}
|
||||
|
||||
public static function getAll($relations = false, $relationscount = false)
|
||||
public static function get($id, $relations = false, $relationsCount = false)
|
||||
{
|
||||
return self::getModelRelations($relations, $relationscount)->get();
|
||||
return self::getModelRelations($relations, $relationsCount)->find($id);
|
||||
}
|
||||
|
||||
public static function getModelRelations($relations = false, $relationscount = false)
|
||||
public static function getWithTrashed($id, $relations = false, $relationsCount = false)
|
||||
{
|
||||
return self::getModelRelations($relations, $relationsCount)->withTrashed()->find($id);
|
||||
}
|
||||
|
||||
public static function getAll($relations = false, $relationsCount = false)
|
||||
{
|
||||
return self::getModelRelations($relations, $relationsCount)->get();
|
||||
}
|
||||
|
||||
public static function getRevisions($id)
|
||||
{
|
||||
$model = self::get($id, ['revisions.user'])->toArray();
|
||||
|
||||
return collect($model['revisions'])->sortBy('created_at')->reverse()->toArray();
|
||||
}
|
||||
|
||||
public static function getModelRelations($relations = false, $relationsCount = false)
|
||||
{
|
||||
$model = $relations ? self::getModelWithRelations($relations) : false;
|
||||
$model = $relationscount ? self::getModelWithCountRelations($relationscount, $model) : $model;
|
||||
$model = $relationsCount ? self::getModelWithCountRelations($relationsCount, $model) : $model;
|
||||
|
||||
return $model ? $model : self::getModel();
|
||||
}
|
||||
@@ -153,8 +179,12 @@ trait Basic
|
||||
return is_object($model) ? $model->withCount($relations) : self::getModel()->withCount($relations);
|
||||
}
|
||||
|
||||
public static function getModel(): Model
|
||||
public static function getModel($stopStamping = false): Model
|
||||
{
|
||||
return new Model();
|
||||
$model = new Model();
|
||||
if ($stopStamping) {
|
||||
$model->stopUserstamping();
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,10 +22,28 @@ trait Imageable
|
||||
|
||||
public function registerMediaConversions(Media $media = null): void
|
||||
{
|
||||
$this->addMediaConversion('thumb')->fit(Manipulations::FIT_CROP, 32, 32);
|
||||
$this->addMediaConversion('mini')->fit(Manipulations::FIT_CROP, 96, 96);
|
||||
$this->addMediaConversion('preview')->fit(Manipulations::FIT_CROP, 160, 160);
|
||||
$this->addMediaConversion('normal')->fit(Manipulations::FIT_CROP, 480, 480);
|
||||
$watermark = public_path('img/watermark.png');
|
||||
|
||||
$this->addMediaConversion('thumb')->fit(Manipulations::FIT_CROP, 32, 32)
|
||||
->watermark($watermark)
|
||||
->watermarkHeight(100, Manipulations::UNIT_PERCENT)
|
||||
->watermarkWidth(100, Manipulations::UNIT_PERCENT)
|
||||
->watermarkFit(Manipulations::FIT_FILL);
|
||||
$this->addMediaConversion('mini')->fit(Manipulations::FIT_CROP, 96, 96)
|
||||
->watermark($watermark)
|
||||
->watermarkHeight(100, Manipulations::UNIT_PERCENT)
|
||||
->watermarkWidth(100, Manipulations::UNIT_PERCENT)
|
||||
->watermarkFit(Manipulations::FIT_FILL);
|
||||
$this->addMediaConversion('preview')->fit(Manipulations::FIT_CROP, 160, 160)
|
||||
->watermark($watermark)
|
||||
->watermarkHeight(100, Manipulations::UNIT_PERCENT)
|
||||
->watermarkWidth(100, Manipulations::UNIT_PERCENT)
|
||||
->watermarkFit(Manipulations::FIT_FILL);
|
||||
$this->addMediaConversion('normal')->fit(Manipulations::FIT_CROP, 480, 480)
|
||||
->watermark($watermark)
|
||||
->watermarkHeight(100, Manipulations::UNIT_PERCENT)
|
||||
->watermarkWidth(100, Manipulations::UNIT_PERCENT)
|
||||
->watermarkFit(Manipulations::FIT_FILL);
|
||||
// $this->addMediaConversion('zoom')->fit(Manipulations::FIT_CROP, 1200, 1200)->withResponsiveImages();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user