[WIP] Order process
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Datatables\Botanic;
|
||||
|
||||
use App\Repositories\Shop\Tags;
|
||||
use Yajra\DataTables\Html\Column;
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Botanic\Specie;
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Http\Controllers\Admin\Core\Auth;
|
||||
|
||||
use Auth;
|
||||
use Image;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Intervention\Image\Facades\Image;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
@@ -40,8 +40,6 @@ class ResetPasswordController extends Controller
|
||||
|
||||
public function showResetForm(Request $request, $token = null)
|
||||
{
|
||||
dump('ici');
|
||||
exit;
|
||||
$data['token'] = $token;
|
||||
$data['email'] = $request->email;
|
||||
return view('auth.passwords.reset', $data);
|
||||
|
||||
40
app/Http/Controllers/Shop/Auth/ConfirmPasswordController.php
Normal file
40
app/Http/Controllers/Shop/Auth/ConfirmPasswordController.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Shop\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Illuminate\Foundation\Auth\ConfirmsPasswords;
|
||||
|
||||
class ConfirmPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Confirm Password Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password confirmations and
|
||||
| uses a simple trait to include the behavior. You're free to explore
|
||||
| this trait and override any functions that require customization.
|
||||
|
|
||||
*/
|
||||
|
||||
use ConfirmsPasswords;
|
||||
|
||||
/**
|
||||
* Where to redirect users when the intended url fails.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
}
|
||||
@@ -3,22 +3,27 @@
|
||||
namespace App\Http\Controllers\Shop\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Contracts\View\View;
|
||||
|
||||
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
|
||||
class ForgotPasswordController extends Controller
|
||||
{
|
||||
use SendsPasswordResetEmails;
|
||||
|
||||
/**
|
||||
* Get password request form view.
|
||||
*
|
||||
* @return Application|Factory|View
|
||||
*/
|
||||
protected function guard()
|
||||
{
|
||||
return Auth::guard('customer');
|
||||
}
|
||||
|
||||
public function broker()
|
||||
{
|
||||
return Password::broker('customers');
|
||||
}
|
||||
|
||||
public function showLinkRequestForm()
|
||||
{
|
||||
return view('boilerplate::auth.passwords.email');
|
||||
return view('Shop.auth.passwords.email');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,8 +25,7 @@ class LoginController extends Controller
|
||||
|
||||
public function showLoginForm()
|
||||
{
|
||||
$data['url'] = route('Shop.login.post');
|
||||
return view('Shop.auth.login', $data);
|
||||
return view('Shop.auth.login');
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
@@ -36,7 +35,7 @@ class LoginController extends Controller
|
||||
'password' => 'required|min:8',
|
||||
]);
|
||||
|
||||
if (Auth::guard('customer')->attempt($credentials, $request->get('remember'))) {
|
||||
if ($this->guard()->attempt($credentials, $request->get('remember'))) {
|
||||
$request->session()->regenerate();
|
||||
return redirect()->intended(route('home'));
|
||||
}
|
||||
|
||||
@@ -2,9 +2,12 @@
|
||||
|
||||
namespace App\Http\Controllers\Shop\Auth;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
use App\Rules\Password as PasswordRules;
|
||||
|
||||
class ResetPasswordController extends Controller
|
||||
{
|
||||
@@ -19,8 +22,29 @@ class ResetPasswordController extends Controller
|
||||
|
||||
public function showResetForm(Request $request, $token = null)
|
||||
{
|
||||
$data['token'] = $token;
|
||||
$data['email'] = $request->email;
|
||||
return view('Auth.passwords.reset', $data);
|
||||
$token = $request->route()->parameter('token');
|
||||
|
||||
return view('Shop.auth.passwords.reset')->with(
|
||||
['token' => $token, 'email' => $request->email]
|
||||
);
|
||||
}
|
||||
|
||||
protected function rules()
|
||||
{
|
||||
return [
|
||||
'token' => 'required',
|
||||
'email' => 'required|email',
|
||||
'password' => ['required', 'confirmed', new PasswordRules()],
|
||||
];
|
||||
}
|
||||
|
||||
public function broker()
|
||||
{
|
||||
return Password::broker('customers');
|
||||
}
|
||||
|
||||
protected function guard()
|
||||
{
|
||||
return Auth::guard('customer');
|
||||
}
|
||||
}
|
||||
|
||||
41
app/Http/Controllers/Shop/Auth/VerificationController.php
Normal file
41
app/Http/Controllers/Shop/Auth/VerificationController.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Shop\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\VerifiesEmails;
|
||||
|
||||
class VerificationController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Email Verification Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling email verification for any
|
||||
| user that recently registered with the application. Emails may also
|
||||
| be re-sent if the user didn't receive the original email message.
|
||||
|
|
||||
*/
|
||||
|
||||
use VerifiesEmails;
|
||||
|
||||
/**
|
||||
* Where to redirect users after verification.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
$this->middleware('signed')->only('verify');
|
||||
$this->middleware('throttle:6,1')->only('verify', 'resend');
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Commercial;
|
||||
namespace App\Http\Controllers\Shop;
|
||||
|
||||
use App\Http\Controllers\Controller as ParentController;
|
||||
|
||||
|
||||
@@ -9,47 +9,27 @@ use App\Repositories\Shop\Customers;
|
||||
|
||||
class CustomerController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Customer $customer
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(Customer $customer)
|
||||
public function show($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Customer $customer
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Customer $customer)
|
||||
public function edit(C$id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Customer $customer
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, Customer $customer)
|
||||
public function update(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Customer $customer
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Customer $customer)
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function profile($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers\Shop;
|
||||
|
||||
use App\Models\Shop\Invoice;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
@@ -9,79 +10,14 @@ use App\Repositories\Shop\Invoices;
|
||||
|
||||
class InvoiceController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
public function show($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 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\Invoice $invoice
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(Invoice $invoice)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Invoice $invoice
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Invoice $invoice)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Invoice $invoice
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, Invoice $invoice)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Invoice $invoice
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Invoice $invoice)
|
||||
{
|
||||
//
|
||||
$data = Invoices::get($id);
|
||||
return view('Shop.Invoices.show', $data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use App\Repositories\Core\User\ShopCart;
|
||||
use App\Repositories\Shop\Deliveries;
|
||||
use App\Repositories\Shop\Orders;
|
||||
use App\Repositories\Shop\Offers;
|
||||
use App\Repositories\Shop\SaleChannels;
|
||||
@@ -15,7 +16,15 @@ class OrderController extends Controller
|
||||
public function order()
|
||||
{
|
||||
$data['basket'] = ShopCart::getSummary();
|
||||
$data['deliveries'] = Deliveries::getAllWithSaleChannel()->toArray();
|
||||
$data['sale_channel'] = SaleChannels::getDefault();
|
||||
return view('Shop.Orders.order', $data);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$data = $request->all();
|
||||
dump($data);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,9 +11,10 @@ class SearchController extends Controller
|
||||
{
|
||||
public function search(Request $request)
|
||||
{
|
||||
$articles = Searches::getResults($request->input());
|
||||
$data = [
|
||||
'articles' => Searches::getResults($request->input()),
|
||||
'articles_count' => $data['articles'] ? count($data['articles']) : 0,
|
||||
'articles' => $articles,
|
||||
'articles_count' => $articles ? count($articles) : 0,
|
||||
'search' => $request->input(),
|
||||
'product_type' => $request->input('product_type'),
|
||||
];
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace App\Models\Core\Auth;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Yadahan\AuthenticationLog\AuthenticationLogable;
|
||||
// use HighIdeas\UsersOnline\Traits\UsersOnlineTrait;
|
||||
use Sebastienheyd\Boilerplate\Models\User as parentUser;
|
||||
@@ -12,22 +11,23 @@ use Sebastienheyd\Boilerplate\Models\User as parentUser;
|
||||
class User extends parentUser
|
||||
{
|
||||
// use UserHasTeams, UsersOnlineTrait;
|
||||
use AuthenticationLogable, SoftDeletes;
|
||||
use AuthenticationLogable;
|
||||
|
||||
protected $fillable = ['active', 'last_name', 'first_name', 'username', 'email', 'password', 'remember_token', 'last_login'];
|
||||
protected $hidden = ['password', 'remember_token'];
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
'settings' => 'array',
|
||||
];
|
||||
|
||||
public function passwordSecurity()
|
||||
{
|
||||
return $this->hasOne('App\Models\Core\Auth\PasswordSecurity');
|
||||
return $this->hasOne(PasswordSecurity::class);
|
||||
}
|
||||
|
||||
public function teams()
|
||||
{
|
||||
return $this->hasManyThrough(Team::class, TeamUser::class, 'user_id', 'id', 'id', 'team_id');
|
||||
return $this->belongsToMany(Team::class, TeamUser::class);
|
||||
}
|
||||
|
||||
public function scopeByTeam($query, $id)
|
||||
|
||||
@@ -4,18 +4,22 @@ namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Yadahan\AuthenticationLog\AuthenticationLogable;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Yadahan\AuthenticationLog\AuthenticationLogable;
|
||||
use App\Notifications\NewUser;
|
||||
use App\Notifications\ResetPassword;
|
||||
use App\Notifications\VerifyEmail;
|
||||
|
||||
class Customer extends Authenticatable
|
||||
{
|
||||
use AuthenticationLogable, SoftDeletes;
|
||||
use AuthenticationLogable, Notifiable, SoftDeletes;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_customers';
|
||||
protected $fillable = ['active', 'last_name', 'first_name', 'username', 'email', 'password', 'remember_token', 'settings', 'last_login'];
|
||||
protected $hidden = ['password', 'remember_token'];
|
||||
protected $casts = ['email_verified_at' => 'datetime',];
|
||||
protected $casts = ['email_verified_at' => 'datetime'];
|
||||
|
||||
public function addresses()
|
||||
{
|
||||
@@ -34,7 +38,7 @@ class Customer extends Authenticatable
|
||||
|
||||
public function deliveries()
|
||||
{
|
||||
return $this->belongsToMany(Delivery::class, 'shop_customer_deliveries');
|
||||
return $this->belongsToMany(Delivery::class, CustomerDelivery::class);
|
||||
}
|
||||
|
||||
public function deliveries2()
|
||||
@@ -47,8 +51,16 @@ class Customer extends Authenticatable
|
||||
return $this->hasMany(Order::class);
|
||||
}
|
||||
|
||||
public function User()
|
||||
public function sendEmailVerificationNotification()
|
||||
{
|
||||
return $this->belongsTo('App\User');
|
||||
if (config('boilerplate.auth.verify_email')) {
|
||||
$this->notify(new VerifyEmail());
|
||||
}
|
||||
}
|
||||
|
||||
public function sendPasswordResetNotification($token)
|
||||
{
|
||||
$this->notify(new ResetPassword($token));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
63
app/Notifications/NewUser.php
Normal file
63
app/Notifications/NewUser.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class NewUser extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return string[]
|
||||
*/
|
||||
public function via($notifiable)
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
{
|
||||
$currentUser = \Auth::user();
|
||||
|
||||
return (new MailMessage())
|
||||
->markdown('boilerplate::notifications.email')
|
||||
->greeting(__('boilerplate::notifications.greeting', ['firstname' => $notifiable->first_name]))
|
||||
->subject(__('boilerplate::notifications.newuser.subject', ['name' => config('app.name')]))
|
||||
->line(__('boilerplate::notifications.newuser.intro', [
|
||||
'name' => $currentUser->first_name.' '.$currentUser->last_name,
|
||||
]))
|
||||
->action(
|
||||
__('boilerplate::notifications.newuser.button'),
|
||||
route('boilerplate.users.firstlogin', $notifiable->remember_token)
|
||||
)
|
||||
->salutation(__('boilerplate::notifications.salutation', [
|
||||
'name' => $currentUser->first_name.' '.$currentUser->last_name,
|
||||
]))
|
||||
->line(__('boilerplate::notifications.newuser.outro'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($notifiable)
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
28
app/Notifications/ResetPassword.php
Normal file
28
app/Notifications/ResetPassword.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
|
||||
class ResetPassword extends \Illuminate\Auth\Notifications\ResetPassword
|
||||
{
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
{
|
||||
return (new MailMessage())
|
||||
->markdown('boilerplate::notifications.email')
|
||||
->greeting(__('boilerplate::notifications.greeting', ['firstname' => $notifiable->first_name]))
|
||||
->subject(__('boilerplate::notifications.resetpassword.subject'))
|
||||
->line(__('boilerplate::notifications.resetpassword.intro'))
|
||||
->action(
|
||||
__('boilerplate::notifications.resetpassword.button'),
|
||||
route('Shop.password.reset', $this->token)
|
||||
)
|
||||
->line(__('boilerplate::notifications.resetpassword.outro'));
|
||||
}
|
||||
}
|
||||
44
app/Notifications/VerifyEmail.php
Normal file
44
app/Notifications/VerifyEmail.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use Illuminate\Auth\Notifications\VerifyEmail as BaseEmail;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
|
||||
class VerifyEmail extends BaseEmail
|
||||
{
|
||||
protected function verificationUrl($notifiable)
|
||||
{
|
||||
if (static::$createUrlCallback) {
|
||||
return call_user_func(static::$createUrlCallback, $notifiable);
|
||||
}
|
||||
|
||||
return URL::temporarySignedRoute(
|
||||
'boilerplate.verification.verify',
|
||||
Carbon::now()->addMinutes(Config::get('auth.verification.expire', 60)),
|
||||
[
|
||||
'id' => $notifiable->getKey(),
|
||||
'hash' => sha1($notifiable->getEmailForVerification()),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the verify email notification mail message for the given URL.
|
||||
*
|
||||
* @param string $url
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
protected function buildMailMessage($url)
|
||||
{
|
||||
return (new MailMessage)
|
||||
->markdown('boilerplate::notifications.email')
|
||||
->subject(__('Verify Email Address'))
|
||||
->line(__('Please click the button below to verify your email address.'))
|
||||
->action(__('Verify Email Address'), $url)
|
||||
->line(__('If you did not create an account, no further action is required.'));
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,9 @@ class Cities
|
||||
// dump($adresse);
|
||||
$geocode = app('geocoder')->geocode($adresse)->get();
|
||||
// dump($geocode);
|
||||
if (count($geocode)) {
|
||||
if (!count($geocode)) {
|
||||
return false;
|
||||
}
|
||||
// dump($geocode);
|
||||
$res = $geocode[0]->getCoordinates()->toArray();
|
||||
// dump($res);
|
||||
@@ -53,9 +55,7 @@ class Cities
|
||||
// dump($latitude);
|
||||
// dump($longitude);
|
||||
return ['latitude' => $latitude, 'longitude' => $longitude];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function getCoordsByCity($id)
|
||||
|
||||
@@ -133,7 +133,8 @@ class Debug
|
||||
dump($msg);
|
||||
}
|
||||
|
||||
if (self::isDebug()) {
|
||||
if (!self::isDebug()){
|
||||
return;}
|
||||
if (static::isCLI()) {
|
||||
self::dumpCli($msg, $cat);
|
||||
}
|
||||
@@ -143,7 +144,7 @@ class Debug
|
||||
if (static::isClockwork()) {
|
||||
self::dumpClockwork($msg, $cat);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function dumpDebugbar($msg, $cat = '', $force = false)
|
||||
|
||||
@@ -75,12 +75,16 @@ class Export
|
||||
if (isset($options[$key])) {
|
||||
$txt = $options[$key][$txt];
|
||||
}
|
||||
if (isset($multioptions[$key])) {
|
||||
if (!isset($multioptions[$key])){
|
||||
$this->writeCell($this->lig, $col, $txt);
|
||||
$this->nb++;
|
||||
$col++;
|
||||
continue;}
|
||||
$tabs = self::getReverseMultiOptions($txt);
|
||||
foreach ($tabs as $key2 => $value) {
|
||||
$txt .= $multioptions[$key][$key2] . '\n';
|
||||
}
|
||||
}
|
||||
|
||||
$this->writeCell($this->lig, $col, $txt);
|
||||
$this->nb++;
|
||||
$col++;
|
||||
@@ -114,7 +118,8 @@ class Export
|
||||
|
||||
public function close()
|
||||
{
|
||||
if (!$this->debug) {
|
||||
if ($this->debug){
|
||||
return;}
|
||||
// Debug::message($this->xls);
|
||||
$objWriter = PHPExcel_IOFactory::createWriter($this->xls, 'Excel2007');
|
||||
// Debug::message($objWriter);
|
||||
@@ -126,7 +131,7 @@ class Export
|
||||
// $objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
$objWriter->save('text.xlsx');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function conv($lig, $col)
|
||||
|
||||
@@ -16,7 +16,6 @@ class File
|
||||
|
||||
public static function checkDir($dir)
|
||||
{
|
||||
// File::isDirectory($path)
|
||||
return is_dir($dir);
|
||||
}
|
||||
|
||||
@@ -27,8 +26,7 @@ class File
|
||||
|
||||
public static function createDir($dir)
|
||||
{
|
||||
Storage::makeDirectory($dir);
|
||||
return true;
|
||||
return mkdir($dir, '0777', true);
|
||||
}
|
||||
|
||||
public static function deleteDir($dir)
|
||||
|
||||
@@ -6,12 +6,15 @@ class Geolocation
|
||||
{
|
||||
public static function getCoords($address, $zipcode, $city)
|
||||
{
|
||||
if (!empty($address) && !empty($zipcode) && !empty($city)) {
|
||||
if (!(!empty($address) && !empty($zipcode) && !empty($city))){
|
||||
return;}
|
||||
$address = $address . ' , ' . $city . ' ' . $zipcode . ' , ' . 'France';
|
||||
|
||||
$geocode = app('geocoder')->geocode($address)->get();
|
||||
|
||||
if (count($geocode)) {
|
||||
if (!count($geocode)) {
|
||||
return false;
|
||||
}
|
||||
$res = $geocode[0]->getCoordinates()->toArray();
|
||||
// dump($res);
|
||||
$longitude = $res[0];
|
||||
@@ -20,11 +23,8 @@ class Geolocation
|
||||
// dump($longitude);
|
||||
// exit;
|
||||
return ['latitude' => $latitude, 'longitude' => $longitude];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static function autocomplete($query)
|
||||
{
|
||||
|
||||
@@ -50,7 +50,8 @@ class Item extends LavaryMenuItem
|
||||
|
||||
foreach ($routes as $pattern) {
|
||||
$arr = [$pattern];
|
||||
if (if_route_pattern($arr)) {
|
||||
if (!if_route_pattern($arr)){
|
||||
continue;}
|
||||
$this->activate();
|
||||
|
||||
if (strstr($this->title, 'circle-o')) {
|
||||
@@ -59,7 +60,6 @@ class Item extends LavaryMenuItem
|
||||
// dump($this);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,8 @@ class Menu extends LavaryMenu
|
||||
{
|
||||
public function make($name, $callback)
|
||||
{
|
||||
if (is_callable($callback)) {
|
||||
if (!is_callable($callback)){
|
||||
return;}
|
||||
if (!array_key_exists($name, $this->menu)) {
|
||||
$this->menu[$name] = new Builder($name, $this->loadConf($name));
|
||||
}
|
||||
@@ -25,5 +26,4 @@ class Menu extends LavaryMenu
|
||||
|
||||
return $this->menu[$name];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,15 +13,12 @@ class ShopCart
|
||||
if (self::has($item['id'])) {
|
||||
if ($update) {
|
||||
self::remove($item['id']);
|
||||
$ret = self::get()->add($item);
|
||||
// $ret = self::get()->update($item['id'], ['quantity' => $item['quantity']]);
|
||||
self::get()->add($item);
|
||||
} else {
|
||||
$ret = self::get()->update($item['id'], ['quantity' => $item['quantity']]);
|
||||
// self::remove($item['id']);
|
||||
// $ret = self::get()->add($item);
|
||||
self::get()->update($item['id'], ['quantity' => $item['quantity']]);
|
||||
}
|
||||
} else {
|
||||
$ret = self::get()->add($item);
|
||||
self::get()->add($item);
|
||||
}
|
||||
return [
|
||||
'count' => self::count(),
|
||||
@@ -73,7 +70,12 @@ class ShopCart
|
||||
|
||||
public static function getTotal()
|
||||
{
|
||||
return number_format(round(self::get()->getTotal(),2),2);
|
||||
return self::fixDecimal(self::get()->getTotal());
|
||||
}
|
||||
|
||||
public static function fixDecimal($number)
|
||||
{
|
||||
return number_format(round($number, 2), 2);
|
||||
}
|
||||
|
||||
public static function getItemQuantity($id)
|
||||
|
||||
@@ -173,14 +173,15 @@ class Articles
|
||||
$articles = self::getArticlesWithOffers($options);
|
||||
foreach ($articles as $article) {
|
||||
$price_lists = $article->offers[0]->tariff->price_lists->toArray();
|
||||
if (count($price_lists)) {
|
||||
if (!is_array($data[$article->name] ?? false)) {
|
||||
$data[$article->name] = self::getDataForSale($article);
|
||||
}
|
||||
$prices = $price_lists[0]['price_list_values'][0];
|
||||
$article_nature_name = strtolower($article->article_nature->name);
|
||||
$data[$article->name][$article_nature_name] = self::getDataPriceForSale($article, $prices);
|
||||
if (!count($price_lists)) {
|
||||
continue;
|
||||
}
|
||||
if (!is_array($data[$article->name] ?? false)) {
|
||||
$data[$article->name] = self::getDataForSale($article);
|
||||
}
|
||||
$prices = $price_lists[0]['price_list_values'][0];
|
||||
$article_nature_name = strtolower($article->article_nature->name);
|
||||
$data[$article->name][$article_nature_name] = self::getDataPriceForSale($article, $prices);
|
||||
}
|
||||
if ($data ?? false) {
|
||||
ksort($data);
|
||||
@@ -511,25 +512,26 @@ class Articles
|
||||
public static function getFullImageByArticle($article)
|
||||
{
|
||||
$image = $article->image;
|
||||
if (!$image) {
|
||||
switch ($article->product_type) {
|
||||
case 'App\Models\Botanic\Variety':
|
||||
$variety = $article->product;
|
||||
$image = $variety->image ?? false;
|
||||
if (!$image) {
|
||||
$specie = $variety->specie;
|
||||
$image = $specie->image ?? false;
|
||||
}
|
||||
break;
|
||||
case 'App\Models\Botanic\Specie':
|
||||
$specie = $article->product;
|
||||
if ($image) {
|
||||
return $image;
|
||||
}
|
||||
switch ($article->product_type) {
|
||||
case 'App\Models\Botanic\Variety':
|
||||
$variety = $article->product;
|
||||
$image = $variety->image ?? false;
|
||||
if (!$image) {
|
||||
$specie = $variety->specie;
|
||||
$image = $specie->image ?? false;
|
||||
break;
|
||||
case 'App\Models\Shop\Merchandise':
|
||||
$merchandise = $article->product;
|
||||
$image = $merchandise->image ?? false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'App\Models\Botanic\Specie':
|
||||
$specie = $article->product;
|
||||
$image = $specie->image ?? false;
|
||||
break;
|
||||
case 'App\Models\Shop\Merchandise':
|
||||
$merchandise = $article->product;
|
||||
$image = $merchandise->image ?? false;
|
||||
break;
|
||||
}
|
||||
return $image;
|
||||
}
|
||||
@@ -581,16 +583,15 @@ class Articles
|
||||
|
||||
public static function storeCategories($article, $categories)
|
||||
{
|
||||
if ($categories) {
|
||||
$categories = collect($categories)->transform(
|
||||
function ($item, $key) {
|
||||
return (int) $item;
|
||||
}
|
||||
)->toArray();
|
||||
return $article->syncCategories($categories, true);
|
||||
} else {
|
||||
if (!$categories) {
|
||||
return false;
|
||||
}
|
||||
$categories = collect($categories)->transform(
|
||||
function ($item, $key) {
|
||||
return (int) $item;
|
||||
}
|
||||
)->toArray();
|
||||
return $article->syncCategories($categories, true);
|
||||
}
|
||||
|
||||
public static function storeTags($article, $tags)
|
||||
|
||||
@@ -116,15 +116,14 @@ class Categories
|
||||
public static function getImages($id)
|
||||
{
|
||||
$category = self::get($id);
|
||||
if ($category) {
|
||||
$category->getMedia();
|
||||
foreach ($category->media as $key => $media) {
|
||||
$category->media[$key]['url'] = $media->getUrl();
|
||||
}
|
||||
return $category->media;
|
||||
} else {
|
||||
if (!$category) {
|
||||
return false;
|
||||
}
|
||||
$category->getMedia();
|
||||
foreach ($category->media as $key => $media) {
|
||||
$category->media[$key]['url'] = $media->getUrl();
|
||||
}
|
||||
return $category->media;
|
||||
}
|
||||
|
||||
public static function deleteImage($id, $index)
|
||||
|
||||
@@ -3,18 +3,56 @@
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use Laravolt\Avatar\Avatar;
|
||||
|
||||
use App\Repositories\Core\File;
|
||||
use App\Models\Shop\Customer;
|
||||
|
||||
class Customers
|
||||
{
|
||||
|
||||
public static function getAvatar()
|
||||
public static function getAvatar($id = false)
|
||||
{
|
||||
|
||||
$customer = $id ? self::get($id) : self::getAuth();
|
||||
$file = self::makeAvatarFilename($customer);
|
||||
if (!File::checkFile($file)) {
|
||||
self::createAvatar($customer);
|
||||
}
|
||||
return self::getPublic(self::getAvatarFilename($customer));
|
||||
}
|
||||
|
||||
public static function createAvatar($customer)
|
||||
{
|
||||
$filename = self::makeAvatarFilename($customer);
|
||||
$name = $customer->first_name . ' ' . $customer->last_name;
|
||||
$avatar = new Avatar();
|
||||
$ret = $avatar->create($name)
|
||||
->setBackground($bgColor)
|
||||
->setBorder(1, '#29292e')
|
||||
->setFontFamily('Roboto Condensed')
|
||||
->setDimension(40)
|
||||
->setFontSize(16)
|
||||
->save($filename);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function makeAvatarFilename($customer)
|
||||
{
|
||||
$path = storage_path(self::getStorage());
|
||||
if (File::checkDirOrCreate($path)) {
|
||||
$filename = $path . 'user-' . $customer->uuid . '.png';
|
||||
}
|
||||
return $filename ?? false;
|
||||
}
|
||||
|
||||
public static function getAvatarFilename($customer)
|
||||
{
|
||||
return 'user-' . $customer->uuid . '.png';
|
||||
}
|
||||
|
||||
|
||||
public static function getName()
|
||||
{
|
||||
$user = self::getAuth();
|
||||
@@ -85,16 +123,15 @@ class Customers
|
||||
|
||||
public static function storeDeliveries($customer, $deliveries)
|
||||
{
|
||||
if ($deliveries) {
|
||||
$deliveries = collect($deliveries)->transform(
|
||||
function ($item, $key) {
|
||||
return (int) $item;
|
||||
}
|
||||
)->toArray();
|
||||
return $customer->deliveries()->sync($deliveries);
|
||||
} else {
|
||||
if (!$deliveries) {
|
||||
return false;
|
||||
}
|
||||
$deliveries = collect($deliveries)->transform(
|
||||
function ($item, $key) {
|
||||
return (int) $item;
|
||||
}
|
||||
)->toArray();
|
||||
return $customer->deliveries()->sync($deliveries);
|
||||
}
|
||||
|
||||
public static function storeAddresses($customer, $addresses)
|
||||
@@ -107,6 +144,7 @@ class Customers
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
$data['uuid'] = Str::uuid()->toString();
|
||||
return Customer::create($data);
|
||||
}
|
||||
|
||||
@@ -122,4 +160,16 @@ class Customers
|
||||
{
|
||||
return Customer::destroy($id);
|
||||
}
|
||||
|
||||
public static function getStorage($filename = false)
|
||||
{
|
||||
$path = '/app/public/Customers/';
|
||||
return $filename ? $path . $filename : $path;
|
||||
}
|
||||
|
||||
public static function getPublic($filename = false)
|
||||
{
|
||||
$path = '/storage/Customers/';
|
||||
return $filename ? $path . $filename : $path;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,11 @@ class Deliveries
|
||||
return Delivery::orderBy('name', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function getAllWithSaleChannel()
|
||||
{
|
||||
return Delivery::orderBy('name', 'asc')->active()->public()->with('sale_channel')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return Delivery::find($id);
|
||||
|
||||
@@ -21,13 +21,14 @@ class TagGroups
|
||||
$tag_groups = TagGroup::pluck('name', 'id')->toArray();
|
||||
foreach ($tags as $tag) {
|
||||
$data[$tag['tag_group_id']]['name'] = $tag_groups[$tag['tag_group_id']];
|
||||
if ($tag['articles_count']) {
|
||||
$data[$tag['tag_group_id']]['tags'][] = [
|
||||
'id' => $tag['id'],
|
||||
'name' => $tag['name'],
|
||||
'count' => $tag['articles_count'],
|
||||
];
|
||||
}
|
||||
if (!$tag['articles_count']) {
|
||||
continue;
|
||||
}
|
||||
$data[$tag['tag_group_id']]['tags'][] = [
|
||||
'id' => $tag['id'],
|
||||
'name' => $tag['name'],
|
||||
'count' => $tag['articles_count'],
|
||||
];
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
59
app/Rules/Password.php
Normal file
59
app/Rules/Password.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Rules;
|
||||
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
|
||||
class Password implements Rule
|
||||
{
|
||||
private $length;
|
||||
private $message;
|
||||
|
||||
/**
|
||||
* Create a new rule instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($length = 8)
|
||||
{
|
||||
$this->length = $length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the validation rule passes.
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function passes($attribute, $value)
|
||||
{
|
||||
$rules = [
|
||||
'#.{'.$this->length.',}#' => 'boilerplate::password.rules.length',
|
||||
'#[a-z]+#' => 'boilerplate::password.rules.letter',
|
||||
'#[A-Z]+#' => 'boilerplate::password.rules.capital',
|
||||
'#[0-9]+#' => 'boilerplate::password.rules.number',
|
||||
'#[^A-Za-z0-9]+#' => 'boilerplate::password.rules.special',
|
||||
];
|
||||
|
||||
foreach ($rules as $rule => $msg) {
|
||||
if (! preg_match($rule, $value)) {
|
||||
$this->message = __($msg, ['min' => $this->length]);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation error message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function message()
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
}
|
||||
111
app/Traits/Auth/SendsPasswordResetEmails.php
Normal file
111
app/Traits/Auth/SendsPasswordResetEmails.php
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
namespace App\Traits\Auth;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
trait SendsPasswordResetEmails
|
||||
{
|
||||
/**
|
||||
* Display the form to request a password reset link.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function showLinkRequestForm()
|
||||
{
|
||||
return view('auth.passwords.email');
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a reset link to the given user.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function sendResetLinkEmail(Request $request)
|
||||
{
|
||||
$this->validateEmail($request);
|
||||
|
||||
// We will send the password reset link to this user. Once we have attempted
|
||||
// to send the link, we will examine the response then see the message we
|
||||
// need to show to the user. Finally, we'll send out a proper response.
|
||||
$response = $this->broker()->sendResetLink(
|
||||
$this->credentials($request)
|
||||
);
|
||||
|
||||
return $response == Password::RESET_LINK_SENT
|
||||
? $this->sendResetLinkResponse($request, $response)
|
||||
: $this->sendResetLinkFailedResponse($request, $response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the email for the given request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return void
|
||||
*/
|
||||
protected function validateEmail(Request $request)
|
||||
{
|
||||
$request->validate(['email' => 'required|email']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the needed authentication credentials from the request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
protected function credentials(Request $request)
|
||||
{
|
||||
return $request->only('email');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the response for a successful password reset link.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param string $response
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
|
||||
*/
|
||||
protected function sendResetLinkResponse(Request $request, $response)
|
||||
{
|
||||
return $request->wantsJson()
|
||||
? new JsonResponse(['message' => trans($response)], 200)
|
||||
: back()->with('status', trans($response));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the response for a failed password reset link.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param string $response
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
protected function sendResetLinkFailedResponse(Request $request, $response)
|
||||
{
|
||||
if ($request->wantsJson()) {
|
||||
throw ValidationException::withMessages([
|
||||
'email' => [trans($response)],
|
||||
]);
|
||||
}
|
||||
|
||||
return back()
|
||||
->withInput($request->only('email'))
|
||||
->withErrors(['email' => trans($response)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the broker to be used during password reset.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Auth\PasswordBroker
|
||||
*/
|
||||
public function broker()
|
||||
{
|
||||
return Password::broker();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user