Skip to content

Instantly share code, notes, and snippets.

@chelohl11
chelohl11 / ProductRequest.php
Created October 27, 2023 22:25 — forked from innovacode-online/ProductRequest.php
Product request for inventory project
public function rules(): array
{
return [
'name' => 'required|unique:products,name',
'description' => 'required',
'stock' => 'required',
'price' => 'required',
'category_id' => 'required',
];
}
public function run(): void
{
DB::table('categories')->insert([
'name' => 'Computadoras',
'slug' => 'computadoras',
'created_at' => Carbon::now(),
'updated_at' => Carbon::now(),
]);
DB::table('categories')->insert([
'name' => 'Celulares',
@chelohl11
chelohl11 / BackupController.php
Created March 23, 2020 17:50
Laravel + Spatie Backup controller & views to see and manage DB backup files in the browser -- PLEASE DO NOT ASK FOR SUPPORT
<?php
namespace App\Http\Controllers;
use Alert;
use App\Http\Requests;
use Artisan;
use Log;
use Storage;
@chelohl11
chelohl11 / Laravel-Container.md
Created September 25, 2018 18:04
Laravel's Dependency Injection Container in Depth

Laravel's Dependency Injection Container in Depth

Translations: Korean (by Yongwoo Lee)

Laravel has a powerful Inversion of Control (IoC) / Dependency Injection (DI) Container. Unfortunately the official documentation doesn't cover all of the available functionality, so I decided to experiment with it and document it for myself. The following is based on Laravel 5.4.26 - other versions may vary.

Introduction to Dependency Injection

I won't attempt to explain the principles behind DI / IoC here - if you're not familiar with them you might want to read What is Dependency Injection? by Fabien Potencier (creator of the Symfony framework).

HomeController::class => \DI\create()->constructor(\DI\get(Doctrine::class)),
@chelohl11
chelohl11 / gist:2bb09719beb938a23329d5e3d06b8de4
Created November 2, 2017 20:48
Codigo DataTables buscadores por columna en la parte superior
orderCellsTop: true,
initComplete: function () {
$('#tableListarItems thead tr:eq(1) th.buscar').each( function () {
$(this).html( '<input type="text" class="form-control" style="width:100%;"/>' );
});
table.columns([1,2,3,4]).every(function (index) {
$('#tableListarItems thead tr:eq(1) th:eq(' + index + ') input').on('change', function () {