Skip to content

Commit

Permalink
crear producto y mostrar alerta
Browse files Browse the repository at this point in the history
  • Loading branch information
SantiagoSierra committed Jun 17, 2022
1 parent 9f26c24 commit 8a27fdc
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
11 changes: 10 additions & 1 deletion app/Http/Controllers/ProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,16 @@ public function create()
*/
public function store(Request $request)
{
//
$request->validate([
'ProductName' => 'required',
'ProductStatus' => 'required',
'NumberOfLicenses' => 'required',
'LicenseDuration' => 'required'
]);

$product = Product::create($request->all());

return back()->withStatus(__('Producto '.$product->ProductName.' creado correctamente.'));
}

/**
Expand Down
5 changes: 5 additions & 0 deletions app/Models/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,9 @@
class Product extends Model
{
//
protected $fillable = ['ProductStatus', 'ProductName', 'NumberOfLicenses', 'LicenseDuration'];




}
18 changes: 12 additions & 6 deletions resources/views/products/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@section('content')
<form method="post" action="{{ route('products.store') }}" enctype="multipart/form-data">
@csrf
@include('alerts.success')
<div class="row">

<div class="col-md-8">
Expand All @@ -16,18 +17,18 @@
<div class="mx-md-1 col-md-5">
<div class="form-group">
<label>{{ __('Name') }}</label>
<input type="text" class="form-control" placeholder="{{ __('Nombre prodcuto') }}" name="name" value="">
@include('alerts.feedback', ['field' => 'name'])
<input type="text" class="form-control" placeholder="{{ __('Nombre prodcuto') }}" name="ProductName" value="">
@include('alerts.feedback', ['field' => 'ProductName'])
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>{{ __('Estado') }}</label>
<select type="text" class="form-control" name="status" style="background-color: #2b3553;" title="{{ __('Estado') }}">
<select type="text" class="form-control" name="ProductStatus" style="background-color: #2b3553;" title="{{ __('Estado') }}">
<option value="1" selected>Activo</option>
<option value="0">Desactivado</option>
</select>
@include('alerts.feedback', ['field' => 'status'])
@include('alerts.feedback', ['field' => 'ProductStatus'])
</div>
</div>
</div>
Expand All @@ -37,12 +38,17 @@
<div class="mx-md-1 col-md-5">
<div class="form-group">
<label>{{ __('Numero de licencias') }}</label>
<input type="number" class="form-control" placeholder="{{ __('Numero de licencias') }}" name="numberOfLicenses" value="">
@include('alerts.feedback', ['field' => 'numberOfLicenses'])
<input type="number" class="form-control" placeholder="{{ __('Numero de licencias') }}" name="NumberOfLicenses" value="">
@include('alerts.feedback', ['field' => 'NumberOfLicenses'])
</div>
</div>

<div class="col-md-6">
<div class="form-group">
<label>{{ __('Cantidad de meses') }}</label>
<input type="number" class="form-control" placeholder="{{ __('Cantidad de meses') }}" name="LicenseDuration" value="">
@include('alerts.feedback', ['field' => 'LicenseDuration'])
</div>
</div>
</div>

Expand Down

0 comments on commit 8a27fdc

Please sign in to comment.