rename models and associates, isolate botanic with shop
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
namespace App\Repositories\Botanic;
|
||||
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@@ -8,7 +8,7 @@ use Illuminate\Support\Str;
|
||||
|
||||
use Yajra\DataTables\DataTables;
|
||||
|
||||
use App\Models\Shop\Family;
|
||||
use App\Models\Botanic\Family;
|
||||
|
||||
class Families
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
namespace App\Repositories\Botanic;
|
||||
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@@ -8,7 +8,7 @@ use Illuminate\Support\Str;
|
||||
|
||||
use Yajra\DataTables\DataTables;
|
||||
|
||||
use App\Models\Shop\Genre;
|
||||
use App\Models\Botanic\Genre;
|
||||
|
||||
class Genres
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
namespace App\Repositories\Botanic;
|
||||
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@@ -8,7 +8,7 @@ use Illuminate\Support\Str;
|
||||
|
||||
use Yajra\DataTables\DataTables;
|
||||
|
||||
use App\Models\Shop\Specie;
|
||||
use App\Models\Botanic\Specie;
|
||||
|
||||
class Species
|
||||
{
|
||||
@@ -8,25 +8,25 @@ use Illuminate\Support\Str;
|
||||
|
||||
use Yajra\DataTables\DataTables;
|
||||
|
||||
use App\Models\Shop\Product;
|
||||
use App\Models\Shop\Article;
|
||||
|
||||
class Products
|
||||
class Articles
|
||||
{
|
||||
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = Product::orderBy('name');
|
||||
$model = Article::orderBy('name');
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return Product::orderBy('name','asc')->get();
|
||||
return Article::orderBy('name','asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return Product::find($id);
|
||||
return Article::find($id);
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
@@ -38,17 +38,17 @@ class Products
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return Product::create($data);
|
||||
return Article::create($data);
|
||||
}
|
||||
|
||||
public static function update($data)
|
||||
{
|
||||
return Product::find($id)->update($data);
|
||||
return Article::find($id)->update($data);
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return Product::destroy($id);
|
||||
return Article::destroy($id);
|
||||
}
|
||||
|
||||
}
|
||||
56
app/Repositories/Shop/Categories.php
Normal file
56
app/Repositories/Shop/Categories.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use Yajra\DataTables\DataTables;
|
||||
|
||||
use App\Models\Shop\Categorie;
|
||||
|
||||
class Categories
|
||||
{
|
||||
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = Categorie::orderBy('name');
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return Categorie::orderBy('name','asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return Categorie::find($id);
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$item = $id ? self::update($data) : self::create($data);
|
||||
return $item->id;
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
app('rinvex.categories.category')->create(['name' => $data['name']]);
|
||||
return Categorie::create($data);
|
||||
}
|
||||
|
||||
public static function update($data)
|
||||
{
|
||||
app('rinvex.categories.category')->update(['name' => $data['name']]);
|
||||
return Categorie::find($id)->update($data);
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return Categorie::destroy($id);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user