Skip to content

Instantly share code, notes, and snippets.

View erowsika's full-sized avatar

Edi erowsika

  • Makassar, Indonesia
View GitHub Profile
@erowsika
erowsika / Laravel-Container.md
Created April 13, 2018 16:42
Laravel's Dependency Injection Container in Depth

Laravel's Dependency Injection Container in Depth

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).

Accessing the Container

<template>
<div class="is-child">
<form-wizard
:currentStep="currentView"
@formwizard-step-change="onFormWizardStepChange">
</form-wizard>
</div>
</template>
<script>
// everything u need to do go here
// contoh form input data
// this is same with step2.vue
<template>
</template>
<script>
export default {}
</script>
<?php
namespace AMS\RegistrasiSuratMagang;
use AMS\Models\SuratMasuk;
use AMS\Models\BodySuratKeluarMagang;
use AMS\Models\HeaderSuratKeluarMagang;
use AMS\Http\Requests\StoreRegistrasiSuratMagang;
class RegistrasiSuratMagang
<?php
use AMS\Http\Requests\StoreRegistrasiSuratMagang;
...
public function store(StoreRegistrasiSuratMagang $request, RegistrasiSuratMagang $rsm)
{
$rsm->make($request);
<?php
namespace AMS\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class StoreRegistrasiSuratMagang extends FormRequest
{
/**
@erowsika
erowsika / example
Last active November 29, 2018 18:47
ln -s
// distro Linux Mint 18.3 Sylvia
// linux 4.15.0-39-generic x86_64 (64 bit)
// nginx nginx/1.10.3
// running in local enviroment
// case valid with full path:
// result symlink: example -> /etc/nginx/sites-available/example
user@localhost:/etc/nginx# sudo ln -s sites-available/example /etc/nginx/site-enable/
// case valid without full path:
@erowsika
erowsika / XSSProtection.php
Created July 2, 2020 03:39 — forked from kirkbushell/XSSProtection.php
Laravel 5 XSS protection middleware
class XSSProtection
{
/**
* The following method loops through all request input and strips out all tags from
* the request. This to ensure that users are unable to set ANY HTML within the form
* submissions, but also cleans up input.
*
* @param Request $request
* @param callable $next
* @return mixed
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<main>
<?php
$eror = false;
$pesan = 'Maaf';
//type file yang bisa diupload
$file_type = [
'jpg',
'jpeg',
'gif',
'bmp',