Skip to content

Commit 9ae834b

Browse files
authored
Merge pull request #468 from avored/developed
Developed to master
2 parents 2b2ccf5 + 06b5e50 commit 9ae834b

31 files changed

+126435
-301
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Account;
4+
5+
use App\Http\Controllers\Controller;
6+
use App\Http\Requests\Account\OrderCommentRequest;
7+
use App\Mails\OrderCommentMail;
8+
use AvoRed\Framework\Database\Contracts\ConfigurationModelInterface;
9+
use AvoRed\Framework\Database\Contracts\OrderCommentModelInterface;
10+
use AvoRed\Framework\Database\Models\Customer;
11+
use Illuminate\Support\Facades\Auth;
12+
use Illuminate\Support\Facades\Mail;
13+
14+
class OrderCommentController extends Controller
15+
{
16+
17+
/**
18+
* Order Comment Repository
19+
* @param OrderCommentRepository $orderCommentRepository
20+
*/
21+
protected $orderCommentRepository;
22+
/**
23+
* Configuration Repository
24+
* @param ConfigurationRepository $configurationRepository
25+
*/
26+
protected $configurationRepository;
27+
28+
29+
/**
30+
* Order Comment Construct
31+
* @param OrderCommentRepository $orderCommentRepository
32+
*/
33+
public function __construct(
34+
OrderCommentModelInterface $orderCommentRepository,
35+
ConfigurationModelInterface $configurationRepository
36+
) {
37+
$this->orderCommentRepository = $orderCommentRepository;
38+
$this->configurationRepository = $configurationRepository;
39+
}
40+
41+
/**
42+
* Store Order Comment into database
43+
* @param int $orderId //Do not need route binding at this stage.
44+
* @param OrderCommentRequest $request
45+
* @return Redirect
46+
*/
47+
public function store($orderId, OrderCommentRequest $request)
48+
{
49+
$data = $request->all();
50+
$data['order_id'] = $orderId;
51+
$data['commentable_id'] = Auth::guard('customer')->user()->id;
52+
$data['commentable_type'] = Customer::class;
53+
$data['is_private'] = false;
54+
55+
$this->orderCommentRepository->create($data);
56+
$email = $this->configurationRepository->getValueByCode('order_email_address');
57+
$url = route('admin.order.show', $orderId);
58+
Mail::to($email)->send(new OrderCommentMail($url));
59+
60+
return redirect()->route('account.order.show', $orderId);
61+
}
62+
63+
}

app/Http/Controllers/Account/OrderController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public function index()
4747
*/
4848
public function show(Order $order)
4949
{
50+
$order->load(['products', 'orderComments.commentable', 'customer', 'shippingAddress.country', 'billingAddress.country']);
5051
return view('account.order.show')
5152
->with(compact('order'));
5253
}

app/Http/Controllers/Auth/ForgotPasswordController.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
use App\Http\Controllers\Controller;
66
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
7+
use Illuminate\Support\Facades\Auth;
8+
use Illuminate\Support\Facades\Password;
79

810
class ForgotPasswordController extends Controller
911
{
@@ -29,4 +31,23 @@ public function __construct()
2931
{
3032
$this->middleware('guest');
3133
}
34+
35+
/**
36+
* Using an Customer Guard for the Auth.
37+
* @return \Illuminate\Auth\SessionGuard
38+
*/
39+
protected function guard()
40+
{
41+
return Auth::guard('customer');
42+
}
43+
44+
/**
45+
* Get the broker to be used during password reset.
46+
*
47+
* @return \Illuminate\Contracts\Auth\PasswordBroker
48+
*/
49+
public function broker()
50+
{
51+
return Password::broker('customers');
52+
}
3253
}

app/Http/Controllers/Auth/RegisterController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ protected function create(array $data)
7777
'first_name' => $data['first_name'],
7878
'last_name' => $data['last_name'],
7979
'email' => $data['email'],
80-
'password' => $data['password'],
80+
'password' => bcrypt($data['password']),
8181
]);
8282
}
8383

app/Http/Controllers/Auth/ResetPasswordController.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
use App\Http\Controllers\Controller;
66
use Illuminate\Foundation\Auth\ResetsPasswords;
7+
use Illuminate\Support\Facades\Auth;
8+
use Illuminate\Support\Facades\Password;
79

810
class ResetPasswordController extends Controller
911
{
@@ -25,7 +27,7 @@ class ResetPasswordController extends Controller
2527
*
2628
* @var string
2729
*/
28-
protected $redirectTo = '/home';
30+
protected $redirectTo = '/';
2931

3032
/**
3133
* Create a new controller instance.
@@ -36,4 +38,23 @@ public function __construct()
3638
{
3739
$this->middleware('guest');
3840
}
41+
42+
/**
43+
* Using an Customer Guard for the Auth.
44+
* @return \Illuminate\Auth\SessionGuard
45+
*/
46+
protected function guard()
47+
{
48+
return Auth::guard('customer');
49+
}
50+
51+
/**
52+
* Get the broker to be used during password reset.
53+
*
54+
* @return \Illuminate\Contracts\Auth\PasswordBroker
55+
*/
56+
public function broker()
57+
{
58+
return Password::broker('customers');
59+
}
3960
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace App\Http\Requests\Account;
4+
5+
use Illuminate\Foundation\Http\FormRequest;
6+
7+
class OrderCommentRequest extends FormRequest
8+
{
9+
/**
10+
* Determine if the user is authorized to make this request.
11+
*
12+
* @return bool
13+
*/
14+
public function authorize()
15+
{
16+
return true;
17+
}
18+
19+
/**
20+
* Get the validation rules that apply to the request.
21+
*
22+
* @return array
23+
*/
24+
public function rules()
25+
{
26+
return [
27+
'content' => 'required'
28+
];
29+
}
30+
}

app/Mails/OrderCommentMail.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace App\Mails;
4+
5+
use AvoRed\Framework\Database\Models\Order;
6+
use Illuminate\Bus\Queueable;
7+
use Illuminate\Mail\Mailable;
8+
use Illuminate\Queue\SerializesModels;
9+
10+
class OrderCommentMail extends Mailable
11+
{
12+
use Queueable, SerializesModels;
13+
14+
/**
15+
* User Order Show Url
16+
* @param string $url
17+
*/
18+
public $url;
19+
20+
21+
public function __construct(string $url)
22+
{
23+
$this->url = $url;
24+
}
25+
/**
26+
* Build the message.
27+
*
28+
* @return $this
29+
*/
30+
public function build()
31+
{
32+
return $this
33+
->subject('Order Comment')
34+
->markdown('mails.comment-mail')
35+
->with('url', $this->url);
36+
}
37+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
1111
},
1212
"dependencies": {
13-
"avored-components": "^0.1.6",
13+
"avored-components": "^0.1",
1414
"axios": "^0.19.2",
1515
"cross-env": "^7.0.2",
1616
"laravel-mix": "^5.0.4",

public/css/app.css

Lines changed: 87446 additions & 1 deletion
Large diffs are not rendered by default.

public/js/app.js

Lines changed: 25702 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)