Skip to content

Commit 450b7af

Browse files
committedOct 30, 2021
v1
1 parent c0e99d6 commit 450b7af

23 files changed

+361
-174
lines changed
 

Diff for: ‎app/Events/MyEvent.php

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
namespace App\Events;
4+
5+
use Illuminate\Broadcasting\Channel;
6+
use Illuminate\Broadcasting\InteractsWithSockets;
7+
use Illuminate\Broadcasting\PresenceChannel;
8+
use Illuminate\Broadcasting\PrivateChannel;
9+
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
10+
use Illuminate\Foundation\Events\Dispatchable;
11+
use Illuminate\Queue\SerializesModels;
12+
13+
class MyEvent implements ShouldBroadcast
14+
{
15+
use Dispatchable, InteractsWithSockets, SerializesModels;
16+
17+
public $message;
18+
19+
/**
20+
* Create a new event instance.
21+
*
22+
* @return void
23+
*/
24+
public function __construct($message)
25+
{
26+
$this->message = $message;
27+
}
28+
29+
/**
30+
* Get the channels the event should broadcast on.
31+
*
32+
* @return \Illuminate\Broadcasting\Channel|array
33+
*/
34+
public function broadcastOn()
35+
{
36+
return ['my-channel'];
37+
}
38+
39+
public function broadcastAs()
40+
{
41+
return 'my-event';
42+
}
43+
}

Diff for: ‎app/Http/Controllers/OrderController.php

+11-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Illuminate\Http\Request;
99
use Illuminate\Support\Facades\DB;
1010

11+
use App\Events\MyEvent;
1112

1213
/**
1314
* Class OrderController
@@ -22,7 +23,7 @@ class OrderController extends Controller
2223
*/
2324
public function index()
2425
{
25-
$orders = Order::paginate();
26+
$orders = Order::orderBy('id', 'DESC')->paginate();
2627
return view('order.index', compact('orders'))
2728
->with('i', (request()->input('page', 1) - 1) * $orders->perPage());
2829

@@ -37,8 +38,7 @@ public function create()
3738
{
3839
$order = new Order();
3940
$category = Category::all();
40-
$product = Product::all();
41-
41+
$product = Product::all();
4242
return view('order.create', compact('order','category','product'));
4343
}
4444

@@ -47,7 +47,11 @@ public function status($id_order,$id_status)
4747
$done = DB::table('orders')
4848
->where('id_order', $id_order)
4949
->update(['status' => $id_status]);
50-
50+
if($id_status==1)
51+
$message= "Pedido ID <font color=blue><b>$id_order</b></font> listo para recoger en COCINA.";
52+
if($id_status==2)
53+
$message= "Pedido ID <font color=blue><b>$id_order</b></font> entregado a CLIENTE.";
54+
event(new MyEvent($message));
5155
return redirect()->route('orders.index')
5256
->with('success', 'Estado de pedido cambiado.');
5357
}
@@ -72,6 +76,9 @@ public function store(Request $request)
7276
$order->save();
7377
}
7478
}
79+
$message= "NUEVO pedido <font color=blue><b>$id_order</b></font> creado para COCINA.";
80+
event(new MyEvent($message));
81+
7582
return redirect()->route('orders.index')
7683
->with('success', 'Pedido creado con éxito.');
7784
}

Diff for: ‎app/Providers/AppServiceProvider.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Illuminate\Support\ServiceProvider;
66
use Illuminate\Support\Facades\Schema;
7-
7+
use Illuminate\Pagination\Paginator;
88

99
class AppServiceProvider extends ServiceProvider
1010
{
@@ -26,5 +26,6 @@ public function register()
2626
public function boot()
2727
{
2828
Schema::defaultStringLength(191);
29+
Paginator::useBootstrap();
2930
}
3031
}

Diff for: ‎composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"laravel/framework": "^8.65",
1212
"laravel/sanctum": "^2.11",
1313
"laravel/tinker": "^2.5",
14-
"laravel/ui": "^3.3"
14+
"laravel/ui": "^3.3",
15+
"pusher/pusher-php-server": "^7.0"
1516
},
1617
"require-dev": {
1718
"facade/ignition": "^2.5",

Diff for: ‎composer.lock

+198-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: ‎config/app.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@
171171
*/
172172
App\Providers\AppServiceProvider::class,
173173
App\Providers\AuthServiceProvider::class,
174-
// App\Providers\BroadcastServiceProvider::class,
174+
App\Providers\BroadcastServiceProvider::class,
175175
App\Providers\EventServiceProvider::class,
176176
App\Providers\RouteServiceProvider::class,
177177

Diff for: ‎resources/views/category/create.blade.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
@endsection
66

77
@section('content')
8-
<section class="content container-fluid">
8+
<section class="content container">
99
<div class="row">
1010
<div class="col-md-12">
1111

1212
@includeif('partials.errors')
1313

1414
<div class="card card-default">
1515
<div class="card-header">
16-
<span class="card-title">Añadir categoría</span>
16+
<span class="card-title"><b>Añadir categoría</b></span>
1717
</div>
1818
<div class="card-body">
1919
<form method="POST" action="{{ route('categories.store') }}" role="form" enctype="multipart/form-data">

Diff for: ‎resources/views/category/edit.blade.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
@endsection
66

77
@section('content')
8-
<section class="content container-fluid">
8+
<section class="content container">
99
<div class="">
1010
<div class="col-md-12">
1111

1212
@includeif('partials.errors')
1313

1414
<div class="card card-default">
1515
<div class="card-header">
16-
<span class="card-title">Modificar categoría</span>
16+
<span class="card-title"><b>Modificar categoría</b></span>
1717
</div>
1818
<div class="card-body">
1919
<form method="POST" action="{{ route('categories.update', $category->id) }}" role="form" enctype="multipart/form-data">

0 commit comments

Comments
 (0)