Add homepage

This commit is contained in:
Ludovic CANDELLIER
2022-03-30 22:23:57 +02:00
parent c50bd2aead
commit eff2cb21c7
27 changed files with 1200 additions and 2549 deletions

View File

@@ -0,0 +1,44 @@
<?php
namespace App\Repositories\Shop;
use App\Models\Shop\Homepage;
class Homepages
{
public static function getLast()
{
$model = Homepage::latest('id')->first();
return $model ? $model->text : '';
}
public static function get($id)
{
return Homepage::find($id);
}
public static function store($data)
{
$item = ($data['id'] ?? false) ? self::update($data) : self::create($data);
return $item->id;
}
public static function create($data)
{
return Homepage::create($data);
}
public static function update($data, $id = false)
{
$id = $id ? $id : $data['id'];
$item = self::get($id);
$item->update($data);
return $item;
}
public static function destroy($id)
{
return Homepage::destroy($id);
}
}