Skip to content

Instantly share code, notes, and snippets.

View umutyerebakmaz's full-sized avatar
:octocat:
I'm available, please open an issue on the subject.

Umut Yerebakmaz umutyerebakmaz

:octocat:
I'm available, please open an issue on the subject.
View GitHub Profile
const temp = this.employees.filter(employee => {
return this.departments.find(department => department.id == employee.departmentId)
}).reduce((mem: any, cur: any) => {
mem[cur.departmentId] = (mem[cur.departmentId] || 0) + 1;
console.log(mem);
return mem;
}, {});
const calculate = Object.keys(temp).map(key => ({
departmentId: key,
@umutyerebakmaz
umutyerebakmaz / ShoppingCartController.php
Last active December 30, 2021 12:36
Laravel 8 Advanced Shopping Cart, Sub Total, Grand Total, Calculate Dynamic Freight Rate Price, Add , Remove, Clear, Remove Selected
<?php
namespace App\Http\Controllers;
use App\Models\FreightRate;
use App\Models\ShoppingCart;
use App\Models\ShoppingSession;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
@umutyerebakmaz
umutyerebakmaz / app.js
Last active November 11, 2021 13:58
Laravel 8 - Bundling AlpineJS component files
import Alpine from 'alpinejs';
import filterComponent from "./components/filter";
window.filterComponent = filterComponent;
window.Alpine = Alpine;
Alpine.start();
@umutyerebakmaz
umutyerebakmaz / Product.php
Created November 10, 2021 19:20
Laravel 8 - PostgreSQL - UUID Trait Fully Worked
<?php
namespace App\Models;
use App\Traits\Uuid;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Product extends Model
@umutyerebakmaz
umutyerebakmaz / alpinejs-tab-image.blade.php
Created September 2, 2021 13:45
Example of Tab Component made using AlpineJS only
<div x-data="{ openTab: 1 }" class="flex flex-col-reverse">
<div class="hidden mt-6 w-full max-w-2xl mx-auto sm:block lg:max-w-none">
<div class="grid grid-cols-4 gap-6" aria-orientation="horizontal" role="tablist">
@foreach ($product->productImages as $productImage)
<button x-on:click="{ openTab = {{ $loop->iteration }} }" id="tabs-1-tab-{{ $loop->iteration }}"
class="relative h-24 bg-white rounded-md flex items-center justify-center text-sm font-medium uppercase text-gray-900 cursor-pointer hover:bg-gray-50 focus:outline-none focus:ring focus:ring-offset-4 focus:ring-opacity-50"
aria-controls="tabs-1-panel-{{ $loop->iteration }}"
:tabindex="openTab === {{ $loop->iteration }} ? 0 : -1"
:aria-selected="openTab === {{ $loop->iteration }} ? 'true' : 'false'"
role="tab"
<div class="max-w-7xl mx-auto overflow-hidden sm:px-6 lg:px-8">
<h2 class="sr-only">Products</h2>
<div class="-mx-px border-l border-gray-200 grid grid-cols-2 sm:mx-0 md:grid-cols-3 lg:grid-cols-4">
<!-- product -->
@foreach ($products as $product)
<div class="group relative p-4 border-r border-b border-gray-200 sm:p-6">
<div class="rounded-lg overflow-hidden bg-gray-200 aspect-w-1 aspect-h-1 group-hover:opacity-75">
<img src="https://tailwindui.com/img/ecommerce-images/category-page-05-image-card-01.jpg" alt="TODO" class="w-full h-full object-center object-cover">
</div>
<div class="pt-10 pb-4 text-center">
export const deleteProduct = async (req, res, next) => {
const response = await productModel.findByIdAndRemove(req.params.productId);
if (!response) {
return next(res.status(200).json({
success: false,
message: 'ürün bulunamadı'
}));
}
else return next(res.status(200).json({
success: true,
// Sorumluluk Alanımdakiler
/**
* Daire Başkanı - county ve neighborhood filtrelemesi olmamalı
* Şube Müdürü - county ve neighborhood filtrelemesi olmamalı
* Şef - county ve neighborhood filtrelemesi olmamalı
* Mesul Müdür - county ve neighborhood filtrelemesi olmamalı
*
* Bölge Sorumlusu - county filtrelemesi olmalı
*
@umutyerebakmaz
umutyerebakmaz / typeorm-conditional-query.resolver.ts
Last active January 26, 2021 14:32
Example of conditional dynamic query technique based on parameter conditions in TypeORM. .where. .andWhere .andWhereIds
@Authorized()
@Query(() => [Coordinate])
async coordinates(
@Arg('filter') filter: CoordinateFilterInput,
): Promise < Coordinate[] > {
console.log(filter);
const query = await getConnection().createQueryBuilder(Coordinate, 'coordinate');
@umutyerebakmaz
umutyerebakmaz / border.scss
Created January 11, 2021 14:30
An example zero error to add infinite dynamic border box
.used-biocidal-box {
border: 1px solid #dddfe2;
padding: 10px 10px;
font-family: 'SF UI Display', sans-serif;
font-size: 14px;
}
.used-biocidal-box:not(:first-child) {
border-top: none;
}