Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
onestartup-shop
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Angel Martin
onestartup-shop
Commits
3b9aced4
Commit
3b9aced4
authored
May 30, 2018
by
Angel MAS
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
notification order
parent
f68b67a4
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
178 additions
and
8 deletions
+178
-8
CartController.php
src/controllers/CartController.php
+37
-8
ClientShop.php
src/models/ClientShop.php
+3
-0
SaleShop.php
src/models/SaleShop.php
+10
-0
ResumenOrder.php
src/notifications/ResumenOrder.php
+80
-0
routes.php
src/routes.php
+2
-0
order.blade.php
src/views/mail/resumen/order.blade.php
+46
-0
No files found.
src/controllers/CartController.php
View file @
3b9aced4
...
...
@@ -18,6 +18,7 @@ use Onestartup\Shop\Payment\MP;
use
Onestartup\Shop\Notifications\PaymentClient
;
use
Onestartup\Shop\Notifications\PaymentAcordarClient
;
use
Onestartup\Shop\Notifications\PaymentClientCard
;
use
Onestartup\Shop\Notifications\ResumenOrder
;
use
PayPal\Rest\ApiContext
;
use
PayPal\Auth\OAuthTokenCredential
;
...
...
@@ -261,6 +262,7 @@ public function shipping()
$client
=
$sale
->
client
;
$items
=
$sale
->
items
;
$addres
=
$client
->
shipping
;
$products
=
$sale
->
products
;
$detail
=
''
;
$status
=
''
;
$user
=
\App\User
::
first
();
...
...
@@ -299,7 +301,8 @@ public function shipping()
\Session
::
forget
(
'cart'
);
\Session
::
forget
(
'sale'
);
$user
->
notify
(
new
PaymentClientCard
(
$client
,
$request
->
paymentMethodId
,
$status
));
$user
->
notify
(
new
ResumenOrder
(
$sale
,
$products
,
$client
,
$addres
));
$client
->
notify
(
new
ResumenOrder
(
$sale
,
$products
,
$client
,
$addres
));
return
redirect
()
->
route
(
'main.shop'
)
...
...
@@ -316,7 +319,9 @@ public function shipping()
\Session
::
forget
(
'cart'
);
\Session
::
forget
(
'sale'
);
$user
->
notify
(
new
PaymentClientCard
(
$client
,
$request
->
paymentMethodId
,
$status
));
//$user->notify(new PaymentClientCard($client, $request->paymentMethodId, $status));
$user
->
notify
(
new
ResumenOrder
(
$sale
,
$products
,
$client
,
$addres
));
$client
->
notify
(
new
ResumenOrder
(
$sale
,
$products
,
$client
,
$addres
));
return
redirect
()
->
route
(
'main.shop'
)
...
...
@@ -358,6 +363,7 @@ public function shipping()
$client
=
$sale
->
client
;
$items
=
$sale
->
items
;
$addres
=
$client
->
shipping
;
$products
=
$sale
->
products
;
$detail
=
''
;
foreach
(
$sale
->
items
as
$item
)
{
...
...
@@ -396,7 +402,8 @@ public function shipping()
\Session
::
forget
(
'sale'
);
$user
=
\App\User
::
first
();
$user
->
notify
(
new
PaymentClient
(
$request
->
payment_id
,
$client
));
$user
->
notify
(
new
ResumenOrder
(
$sale
,
$products
,
$client
,
$addres
));
$client
->
notify
(
new
ResumenOrder
(
$sale
,
$products
,
$client
,
$addres
));
return
redirect
()
...
...
@@ -461,13 +468,15 @@ public function shipping()
$client
=
$sale
->
client
;
$items
=
$sale
->
items
;
$addres
=
$client
->
shipping
;
$products
=
$sale
->
products
;
$sale
->
status
=
2
;
$sale
->
payment_type
=
'Pay Pal'
;
$sale
->
save
();
$user
=
\App\User
::
first
();
$user
->
notify
(
new
PaymentClientCard
(
$client
,
'Paypal'
,
'Pagado'
));
$user
->
notify
(
new
ResumenOrder
(
$sale
,
$products
,
$client
,
$addres
));
$client
->
notify
(
new
ResumenOrder
(
$sale
,
$products
,
$client
,
$addres
));
\Session
::
forget
(
'client'
);
\Session
::
forget
(
'cart'
);
...
...
@@ -511,6 +520,7 @@ public function shipping()
$sale
=
Sale
::
find
(
\Session
::
get
(
'sale'
)
->
id
);
$client
=
$sale
->
client
;
$items
=
$sale
->
items
;
$products
=
$sale
->
products
;
$addres
=
$client
->
shipping
;
$detail
=
''
;
...
...
@@ -619,6 +629,7 @@ public function shipping()
$sale
=
Sale
::
find
(
\Session
::
get
(
'sale'
)
->
id
);
$client
=
$sale
->
client
;
$products
=
$sale
->
products
;
$items
=
$sale
->
items
;
$addres
=
$client
->
shipping
;
$detail
=
''
;
...
...
@@ -633,14 +644,32 @@ public function shipping()
\Session
::
forget
(
'sale'
);
$user
=
\App\User
::
first
();
$user
->
notify
(
new
PaymentAcordarClient
(
'Acordar con el vendedor'
,
$client
));
//
$user->notify(new PaymentAcordarClient('Acordar con el vendedor', $client));
$user
->
notify
(
new
ResumenOrder
(
$sale
,
$products
,
$client
,
$addres
));
$client
->
notify
(
new
ResumenOrder
(
$sale
,
$products
,
$client
,
$addres
));
return
redirect
()
->
route
(
'main.shop'
)
->
with
(
'acordar'
,
'acordar'
);
}
public
function
testmail
()
{
/*$user = \App\User::first();
$orden = Sale::find(27);
$products = $orden->products;
$client = $orden->client;
$shipping = $client->shipping;
//return $products;
//return $shipping->shipping_price->name;
$user->notify(new ResumenOrder($orden, $products, $client, $shipping));*/
return
"Liston"
;
}
}
src/models/ClientShop.php
View file @
3b9aced4
...
...
@@ -3,9 +3,12 @@
namespace
Onestartup\Shop\Model
;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Notifications\Notifiable
;
class
ClientShop
extends
Model
{
use
Notifiable
;
protected
$table
=
'client_shops'
;
protected
$fillable
=
[
'name'
,
...
...
src/models/SaleShop.php
View file @
3b9aced4
...
...
@@ -24,4 +24,14 @@ class SaleShop extends Model
{
return
$this
->
hasMany
(
'Onestartup\Shop\Model\OrderTracking'
,
'sale_id'
);
}
public
function
products
()
{
return
$this
->
belongsToMany
(
'Onestartup\Shop\Model\ProductShop'
,
'detail_shops'
,
'sale_id'
,
'product_id'
)
->
withPivot
(
'quantity'
);
}
}
src/notifications/ResumenOrder.php
0 → 100644
View file @
3b9aced4
<?php
namespace
Onestartup\Shop\Notifications
;
use
Illuminate\Bus\Queueable
;
use
Illuminate\Notifications\Notification
;
use
Illuminate\Contracts\Queue\ShouldQueue
;
use
Illuminate\Notifications\Messages\MailMessage
;
use
Onestartup\Shop\Model\SaleShop
as
Order
;
use
Onestartup\Shop\Model\ClientShop
as
Client
;
use
Onestartup\Shop\Model\ShippingAddres
as
Shipping
;
class
ResumenOrder
extends
Notification
{
use
Queueable
;
protected
$order
;
protected
$products
;
protected
$client
;
protected
$shipping
;
/**
* Create a new notification instance.
*
* @return void
*/
public
function
__construct
(
Order
$order
,
$products
,
Client
$client
,
Shipping
$shipping
)
{
$this
->
order
=
$order
;
$this
->
products
=
$products
;
$this
->
shipping
=
$shipping
;
$this
->
client
=
$client
;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
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
)
{
return
(
new
MailMessage
)
->
subject
(
'Resumen de compra'
)
->
markdown
(
'shop::mail.resumen.order'
,
[
'order'
=>
$this
->
order
,
'products'
=>
$this
->
products
,
'client'
=>
$this
->
client
,
'shipping'
=>
$this
->
shipping
]);
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public
function
toArray
(
$notifiable
)
{
return
[
//
];
}
}
src/routes.php
View file @
3b9aced4
...
...
@@ -100,4 +100,6 @@ Route::group(['middleware' => ['web']], function(){
Route
::
post
(
'cart/paymentPaypal'
,
'Onestartup\Shop\Controller\CartController@paymentPaypal'
)
->
name
(
'cart.paymentPaypal'
);
Route
::
get
(
'cart/successPaypal'
,
'Onestartup\Shop\Controller\CartController@successPaypal'
)
->
name
(
'cart.successPaypal'
);
Route
::
get
(
'cart/cancelPaypal'
,
'Onestartup\Shop\Controller\CartController@cancelPaypal'
)
->
name
(
'cart.cancelPaypal'
);
Route
::
get
(
'cart/testmail'
,
'Onestartup\Shop\Controller\CartController@testmail'
)
->
name
(
'cart.testmail'
);
});
src/views/mail/resumen/order.blade.php
0 → 100644
View file @
3b9aced4
@
php
setlocale
(
LC_MONETARY
,
'en_US'
);
@
endphp
@
component
(
'mail::message'
)
# Resumen de la compra
@
component
(
'mail::panel'
)
-
Numero
de
orden
:
# {{$order->id}}
-
Fecha
:
{{
$order
->
created_at
->
format
(
'd/m/Y'
)}}
-
Forma
de
pago
:
{{
$order
->
payment_type
}}
@
endcomponent
@
component
(
'mail::table'
)
|
Cantidad
|
Producto
|
Precio
|
Subtotal
|
|
:-------------:
|:-------------:|
:--------:|
:-------:|
@
foreach
(
$products
as
$p
)
|
{{
$p
->
pivot
->
quantity
}}
|
{{
$p
->
name
}}
|
{{
money_format
(
'%(#10n'
,
$p
->
infoSale
->
sale_price
)}}
|
{{
money_format
(
'%(#10n'
,
$p
->
infoSale
->
sale_price
*
$p
->
pivot
->
quantity
)}}
|
@
endforeach
|
1
|
{{
$shipping
->
shipping_price
->
name
}}
|
{{
money_format
(
'%(#10n'
,
$shipping
->
shipping_price
->
cost
)}}
|
{{
money_format
(
'%(#10n'
,
$shipping
->
shipping_price
->
cost
)}}
|
|
-
|
-
|
Total
:
|
{{
money_format
(
'%(#10n'
,
$order
->
total
)}}
|
@
endcomponent
@
component
(
'mail::panel'
)
Datos
del
comprador
:
-
Nombre
:
***
{{
$client
->
name
}}
{{
$client
->
lastname
}}
***
-
Teléfono
:
***
{{
$client
->
phone
}}
***
-
Correo
:
***
{{
$client
->
email
}}
***
@
endcomponent
@
component
(
'mail::panel'
)
Datos
de
envio
:
-
Calle
:
***
{{
$shipping
->
calle
}}
Nro
.
{{
$shipping
->
numero
}},
col
.
{{
$shipping
->
colonia
}}
***
-
***
{{
$shipping
->
ciudad
}},
{{
$shipping
->
estado
}},
C
.
P
.
{{
$shipping
->
cp
}}
***
-
Referencias
:
***
{{
$shipping
->
referencias
}}
***
@
endcomponent
Gracias
por
tu
compra
,
<
br
>
{{
config
(
'app.name'
)
}}
@
endcomponent
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment