forked from ansu92/sgcweb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fc7f71d
commit 0b79b60
Showing
14 changed files
with
575 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Models\Servicio; | ||
|
||
class CtrServicio extends Controller | ||
{ | ||
public function index() { | ||
return view('servicio.index'); | ||
} | ||
|
||
public function show(Servicio $servicio) { | ||
return view('servicion.show', compact('servicio')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
namespace App\Http\Livewire\Servicio; | ||
|
||
use App\Models\Categoria; | ||
use App\Models\Servicio; | ||
use Livewire\Component; | ||
|
||
class NuevoServicio extends Component | ||
{ | ||
public $open = false; | ||
|
||
public $nombre, $descripcion, $categoria; | ||
|
||
protected $rules = [ | ||
'nombre' => 'required|max:60|unique:servicios,nombre,NULL,NULL,deleted_at,NULL', | ||
'descripcion' => 'nullable', | ||
'categoria' => 'required|not_in:0', | ||
]; | ||
|
||
public function render() | ||
{ | ||
$categorias = Categoria::all(); | ||
|
||
return view('livewire.servicio.nuevo-servicio', compact('categorias')); | ||
} | ||
|
||
public function updated($propertyName) | ||
{ | ||
$this->validateOnly($propertyName); | ||
} | ||
|
||
public function save() | ||
{ | ||
$this->validate(); | ||
|
||
$servicio = Servicio::withTrashed()->where('nombre', $this->nombre)->first(); | ||
|
||
if ($servicio === null) { | ||
|
||
Servicio::create([ | ||
'nombre' => $this->nombre, | ||
'descripcion' => $this->descripcion, | ||
'categoria_id' => $this->categoria, | ||
]); | ||
} else { | ||
$servicio->restore(); | ||
|
||
$servicio->nombre = $this->nombre; | ||
$servicio->descripcion = $this->descripcion; | ||
$servicio->categoria_id = $this->categoria; | ||
|
||
$servicio->save(); | ||
} | ||
|
||
$this->reset([ | ||
'open', | ||
'nombre', | ||
'descripcion', | ||
'categoria', | ||
]); | ||
|
||
$this->emitTo('servicio.tabla-servicio', 'render'); | ||
$this->emit('alert', 'El servicio se creó satisfactoriamente'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,61 @@ | ||
<!DOCTYPE html> | ||
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<meta name="csrf-token" content="{{ csrf_token() }}"> | ||
|
||
<title>{{ config('app.name', 'Laravel') }}</title> | ||
|
||
<!-- Fonts --> | ||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap"> | ||
|
||
<!-- Styles --> | ||
<link rel="stylesheet" href="{{ mix('css/app.css') }}"> | ||
<link rel="stylesheet" href="{{ asset('vendor/fontawesome-free/css/all.min.css') }}"> | ||
|
||
@livewireStyles | ||
|
||
<!-- Scripts --> | ||
<script src="{{ mix('js/app.js') }}" defer></script> | ||
</head> | ||
<body class="font-sans antialiased"> | ||
<x-jet-banner /> | ||
|
||
<div class="min-h-screen bg-gray-100"> | ||
@livewire('navigation-menu') | ||
|
||
<!-- Page Heading --> | ||
@if (isset($header)) | ||
<header class="bg-white shadow"> | ||
<div class="max-w-7xl mx-auto py-6 px-4 sm:px-6 lg:px-8"> | ||
{{ $header }} | ||
</div> | ||
</header> | ||
@endif | ||
|
||
<!-- Page Content --> | ||
<main> | ||
{{ $slot }} | ||
</main> | ||
</div> | ||
|
||
@stack('modals') | ||
|
||
@livewireScripts | ||
</body> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<meta name="csrf-token" content="{{ csrf_token() }}"> | ||
|
||
<title>{{ config('app.name', 'Laravel') }}</title> | ||
|
||
<!-- Fonts --> | ||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap"> | ||
|
||
<!-- Styles --> | ||
<link rel="stylesheet" href="{{ mix('css/app.css') }}"> | ||
<link rel="stylesheet" href="{{ asset('vendor/fontawesome-free/css/all.min.css') }}"> | ||
|
||
@livewireStyles | ||
|
||
<!-- Scripts --> | ||
<script src="{{ mix('js/app.js') }}" defer></script> | ||
<script src="//cdn.jsdelivr.net/npm/sweetalert2@11"></script> | ||
</head> | ||
|
||
<body class="font-sans antialiased"> | ||
<x-jet-banner /> | ||
|
||
<div class="min-h-screen bg-gray-100"> | ||
@livewire('navigation-menu') | ||
|
||
<!-- Page Heading --> | ||
@if (isset($header)) | ||
<header class="bg-white shadow"> | ||
<div class="max-w-7xl mx-auto py-6 px-4 sm:px-6 lg:px-8"> | ||
{{ $header }} | ||
</div> | ||
</header> | ||
@endif | ||
|
||
<!-- Page Content --> | ||
<main> | ||
{{ $slot }} | ||
</main> | ||
</div> | ||
|
||
@stack('modals') | ||
|
||
@livewireScripts | ||
|
||
<script> | ||
Livewire.on('alert', function(message) { | ||
Swal.fire( | ||
'Good job!', | ||
message, | ||
'success' | ||
) | ||
}); | ||
</script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.