begin order form with registration
This commit is contained in:
@@ -11,8 +11,7 @@ class HomepageController extends Controller
|
||||
{
|
||||
public function index(HomepagesDataTable $dataTable)
|
||||
{
|
||||
$data = [];
|
||||
return $dataTable->render('Admin.Shop.Homepages.list', $data);
|
||||
return $dataTable->render('Admin.Shop.Homepages.list', $data ?? []);
|
||||
}
|
||||
|
||||
public function create()
|
||||
@@ -33,7 +32,7 @@ class HomepageController extends Controller
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$data['homepage'] = Homepages::edit($id);
|
||||
$data['homepage'] = Homepages::get($id);
|
||||
return view('Admin.Shop.Homepages.edit', $data);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,15 +7,7 @@ use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
|
||||
use App\Repositories\Shop\Categories;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
|
||||
public static function init()
|
||||
{
|
||||
$data['categories'] = Categories::getTreeVisibles();
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ class ArticleController extends Controller
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$data = self::init();
|
||||
$data['article'] = Articles::getArticleToSell($id);
|
||||
return view('Shop.Articles.show', $data);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,6 @@ class RegisterController extends Controller
|
||||
|
||||
public function showRegistrationForm()
|
||||
{
|
||||
$data = self::init();
|
||||
return view('Shop.auth.register', $data ?? []);
|
||||
}
|
||||
|
||||
@@ -81,7 +80,6 @@ class RegisterController extends Controller
|
||||
public function emailSendVerification(Request $request)
|
||||
{
|
||||
$request->user()->sendEmailVerificationNotification();
|
||||
|
||||
return back()->with('message', 'Verification link sent!');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ use App\Http\Controllers\Controller;
|
||||
use App\Repositories\Core\User\ShopCart;
|
||||
use App\Repositories\Shop\Offers;
|
||||
use App\Repositories\Shop\Orders;
|
||||
|
||||
use App\Repositories\Users;
|
||||
|
||||
class BasketController extends Controller
|
||||
{
|
||||
@@ -37,10 +37,7 @@ class BasketController extends Controller
|
||||
|
||||
public function basket()
|
||||
{
|
||||
$data = self::init();
|
||||
$data['basket'] = Offers::getBasket();
|
||||
// dump($data['basket']);
|
||||
// exit;
|
||||
return view('Shop.Baskets.basket', $data);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@ use App\Http\Controllers\Controller;
|
||||
|
||||
use App\Repositories\Shop\Articles;
|
||||
use App\Repositories\Shop\Categories;
|
||||
use App\Repositories\Shop\Offers;
|
||||
use App\Repositories\Shop\Tags;
|
||||
use App\Repositories\Shop\TagGroups;
|
||||
|
||||
use App\Datatables\Shop\CategoriesDataTable;
|
||||
@@ -22,23 +20,19 @@ class CategoryController extends Controller
|
||||
|
||||
public function show(Request $request, $category_id)
|
||||
{
|
||||
$data = self::init();
|
||||
$data['category'] = Categories::getFull($category_id);
|
||||
$data['breadcrumb'] = Categories::getAncestorsByCategory($category_id);
|
||||
$data['display_by_rows'] = $request->input('display_by_rows') ?? false;
|
||||
$data['product_type'] = $request->input('product_type') ?? 'botanic';
|
||||
$data['tags_selected'] = $request->input('tags') ?? [];
|
||||
|
||||
$data['articles'] = Articles::getArticlesToSell([
|
||||
'category_id' => $category_id,
|
||||
'tags' => $data['tags_selected'],
|
||||
'product_type' => $data['product_type'],
|
||||
]);
|
||||
// dump($data['articles']);
|
||||
// exit;
|
||||
$data['tags'] = TagGroups::getWithTagsAndCountOffers($category_id);
|
||||
// dump($data['tags']);
|
||||
// exit;
|
||||
$data = [
|
||||
'category' => Categories::getFull($category_id),
|
||||
'breadcrumb' => Categories::getAncestorsByCategory($category_id),
|
||||
'display_by_rows' => $request->input('display_by_rows') ?? false,
|
||||
'product_type' => $request->input('product_type') ?? 'botanic',
|
||||
'tags_selected' => $request->input('tags') ?? [],
|
||||
'articles' => Articles::getArticlesToSell([
|
||||
'category_id' => $category_id,
|
||||
'tags' => $request->input('tags') ?? [],
|
||||
'product_type' => $request->input('product_type') ?? 'botanic',
|
||||
]),
|
||||
'tags' => TagGroups::getWithTagsAndCountOffers($category_id),
|
||||
];
|
||||
return view('Shop.Shelves.shelve', $data);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,4 @@ use App\Http\Controllers\Controller as ParentController;
|
||||
|
||||
class Controller extends ParentController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
// $this->middleware('auth:guest');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,15 +13,13 @@ class HomeController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$input = $request->input();
|
||||
$data = self::init();
|
||||
$data['display_by_rows'] = $input['by_rows'] ?? false;
|
||||
$data['shelves'] = Articles::getArticlesByHomepage();
|
||||
$data['text'] = Homepages::getHomepage();
|
||||
// dump($data['shelves']);
|
||||
// exit;
|
||||
$data['tags'] = TagGroups::getWithTagsAndCountOffers();
|
||||
$data['no_filter'] = true;
|
||||
$data = [
|
||||
'display_by_rows' => $request->input('by_rows') ?? false,
|
||||
'shelves' => Articles::getArticlesByHomepage(),
|
||||
'text' => Homepages::getHomepage(),
|
||||
'tags' => TagGroups::getWithTagsAndCountOffers(),
|
||||
'no_filter' => true,
|
||||
];
|
||||
return view('Shop.home', $data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,83 +5,17 @@ namespace App\Http\Controllers\Shop;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use App\Repositories\Core\User\ShopCart;
|
||||
use App\Repositories\Shop\Orders;
|
||||
use App\Repositories\Shop\Offers;
|
||||
use App\Repositories\Shop\SaleChannels;
|
||||
|
||||
class OrderController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
public function order()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Order $order
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(Order $order)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Order $order
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Order $order)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Order $order
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, Order $order)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Order $order
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Order $order)
|
||||
{
|
||||
//
|
||||
$data['basket'] = ShopCart::getSummary();
|
||||
$data['sale_channel'] = SaleChannels::getDefault();
|
||||
return view('Shop.Orders.order', $data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,11 +11,12 @@ class SearchController extends Controller
|
||||
{
|
||||
public function search(Request $request)
|
||||
{
|
||||
$data = self::init();
|
||||
$data['articles'] = Searches::getResults($request->input());
|
||||
$data['articles_count'] = $data['articles'] ? count($data['articles']) : 0;
|
||||
$data['search'] = $request->input();
|
||||
$data['product_type'] = $request->input('product_type');
|
||||
$data = [
|
||||
'articles'] => Searches::getResults($request->input()),
|
||||
'articles_count' => $data['articles'] ? count($data['articles']) : 0,
|
||||
'search' = $request->input(),
|
||||
'product_type' => $request->input('product_type'),
|
||||
];
|
||||
return view('Shop.Search.results', $data);
|
||||
}
|
||||
}
|
||||
|
||||
20
app/Http/Requests/Shop/StoreOrderPost.php
Normal file
20
app/Http/Requests/Shop/StoreOrderPost.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Shop;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreOrderPost extends FormRequest
|
||||
{
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'user_id' => 'required',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,9 @@ namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Facades\View;
|
||||
|
||||
use App\View\Composers\Shop\LayoutComposer;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
@@ -25,5 +28,6 @@ class AppServiceProvider extends ServiceProvider
|
||||
public function boot()
|
||||
{
|
||||
Schema::defaultStringLength(191);
|
||||
View::composer('Shop.layout.layout', LayoutComposer::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,23 +2,19 @@
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Repositories\Core\Auth\Users;
|
||||
use App\Repositories\Users;
|
||||
use App\Repositories\Shop\Categories;
|
||||
use App\Repositories\Shop\Homepages;
|
||||
|
||||
class Config
|
||||
{
|
||||
public static function init()
|
||||
{
|
||||
$data['user'] = self::getUser();
|
||||
return ['init' => $data];
|
||||
}
|
||||
|
||||
public static function getUser()
|
||||
{
|
||||
if (Users::getUser()) {
|
||||
$data = Users::getInfo();
|
||||
} else {
|
||||
$data = false;
|
||||
}
|
||||
return $data;
|
||||
return [
|
||||
'auth' => Users::getUser() ? Users::getInfo() : false,
|
||||
'categories' => Categories::getTreeVisibles(),
|
||||
'footer' => Homepages::getFooter(),
|
||||
'extra_footer' => Homepages::getExtraFooter(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,18 +7,14 @@ use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use Hyn\Tenancy\Database\Connection;
|
||||
use Laratrust\Traits\LaratrustUserTrait;
|
||||
use LangleyFoxall\LaravelNISTPasswordRules\PasswordRules;
|
||||
|
||||
use App\Models\Core\Auth\User;
|
||||
use App\Models\Core\Auth\RoleUser;
|
||||
|
||||
use App\Repositories\Clients;
|
||||
use App\Repositories\Partners;
|
||||
use App\Repositories\Core\Upload;
|
||||
|
||||
use LangleyFoxall\LaravelNISTPasswordRules\PasswordRules;
|
||||
|
||||
class Users
|
||||
{
|
||||
use LaratrustUserTrait;
|
||||
@@ -38,44 +34,26 @@ class Users
|
||||
$data = $user->toArray();
|
||||
$data['name'] = $user->name;
|
||||
$data['avatar'] = self::getAvatar($id);
|
||||
// $data['last_login'] = $user->previousLoginAt();
|
||||
// $data['roles'] = self::getRoles();
|
||||
// $data['permissions'] = self::getPermissions();
|
||||
$data['roles'] = $user->roles->pluck('id')->toArray();
|
||||
$data['permissions'] = $user->allPermissions()->pluck('id')->toArray();
|
||||
$data['clients'] = $user->clients->pluck('id')->toArray();
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
|
||||
if (!empty($data['password'])) {
|
||||
$data['password'] = Hash::make($data['password']);
|
||||
} else {
|
||||
if ($id) {
|
||||
unset($data['password']);
|
||||
} else {
|
||||
$data['password'] = Hash::make(Str::random(8));
|
||||
}
|
||||
if ($data['id'] ?? false) {
|
||||
unset($data['password']);
|
||||
}
|
||||
$data['remember_token'] = Str::random(32);
|
||||
$data['active'] = true;
|
||||
|
||||
$user = $id ? self::update($data, $id) : self::create($data);
|
||||
$user = ($data['id'] ?? false) ? self::update($data) : self::create($data);
|
||||
$user->roles()->sync(array_keys($data['roles'] ?? []));
|
||||
|
||||
UserClients::associate($user->id, $data['clients'] ?? false );
|
||||
// $user->sendNewUserNotification($data['remember_token'], Auth::user());
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
public static function create($data, $copy_password = false)
|
||||
public static function create($data)
|
||||
{
|
||||
$data['password'] = $copy_password ? $data['password'] : ($data['password'] ? Hash::make($data['password']) : Hash::make(Str::random(8)));
|
||||
$data['password'] = $data['password'] ?? Hash::make($data['password']);
|
||||
$data['remember_token'] = Str::random(32);
|
||||
$data['active'] = true;
|
||||
$user = User::create($data);
|
||||
PasswordSecurities::create($user->id);
|
||||
return $user;
|
||||
@@ -208,7 +186,7 @@ class Users
|
||||
if (!$avatar) {
|
||||
return '/assets/img/no-avatar.png';
|
||||
}
|
||||
$path = Clients::isClient() ? Clients::getPublicPath('/images/avatars/') : Partners::getPublicPath('/images/avatars/');
|
||||
$path = '/images/avatars/';
|
||||
return $path . $avatar;
|
||||
}
|
||||
|
||||
@@ -242,16 +220,6 @@ class Users
|
||||
return User::byUsername($username)->withTrashed()->first();
|
||||
}
|
||||
|
||||
public static function select_by_status_and_team_and_entity($status_id, $team_id, $third_party_id)
|
||||
{
|
||||
return User::active()->byStatus($status_id)->byTeam($team_id)->byThirdParty($third_party_id)->get()->toArray();
|
||||
}
|
||||
|
||||
public static function select_datas_by_id($user_id)
|
||||
{
|
||||
return User::with('status')->find($user_id)->toArray();
|
||||
}
|
||||
|
||||
public static function toggle_active($id, $active)
|
||||
{
|
||||
return self::get($id)->update(['active' => $active]);
|
||||
@@ -276,14 +244,11 @@ class Users
|
||||
public static function update_password($id, $password)
|
||||
{
|
||||
$password = Hash::make($password);
|
||||
UserClients::changePasswordsByUser($id, $password);
|
||||
return User::find($id)->update(['password' => $password]);
|
||||
// $connection = app(Connection::class);
|
||||
// return User::on($connection->systemName())->find($id)->update(['password' => $password]);
|
||||
}
|
||||
|
||||
public static function validate($username, $field = 'current_password')
|
||||
{
|
||||
return PasswordRules::changePassword($username, $field);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -451,7 +451,7 @@ class Articles
|
||||
$tags[$tag['group']][] = $tag['name'];
|
||||
}
|
||||
}
|
||||
return $tags;
|
||||
return $tags ?? null;
|
||||
}
|
||||
|
||||
public static function getPricesByArticle($article)
|
||||
|
||||
@@ -18,6 +18,16 @@ class Homepages
|
||||
return self::get(1)->text;
|
||||
}
|
||||
|
||||
public static function getFooter()
|
||||
{
|
||||
return self::get(2)->text;
|
||||
}
|
||||
|
||||
public static function getExtraFooter()
|
||||
{
|
||||
return self::get(3)->text;
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return Homepage::find($id);
|
||||
|
||||
16
app/Repositories/Users.php
Normal file
16
app/Repositories/Users.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Repositories\Core\Auth\Users as parentUsers;
|
||||
use App\Repositories\Shop\SaleChannels;
|
||||
|
||||
class Users extends parentUsers
|
||||
{
|
||||
public static function getInfo($id = false)
|
||||
{
|
||||
$data = parent::getInfo($id);
|
||||
$data['sale_channel'] = SaleChannels::getDefault()->toArray();
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
14
app/View/Composers/Shop/LayoutComposer.php
Normal file
14
app/View/Composers/Shop/LayoutComposer.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Composers\Shop;
|
||||
|
||||
use Illuminate\View\View;
|
||||
use App\Repositories\Config;
|
||||
|
||||
class LayoutComposer
|
||||
{
|
||||
public function compose(View $view)
|
||||
{
|
||||
$view->with(Config::init());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user