Skip to content

Instantly share code, notes, and snippets.

View ferdiunal's full-sized avatar
🏠
Working from home

Ferdi ÜNAL ferdiunal

🏠
Working from home
View GitHub Profile
<?php
Route::group(['middleware' => 'web'],function(){
Route::get('post',['as' => 'post.index','uses' => 'PostController@index']); // Burada Post sayfasını görüntüleyeceğiz.
Route::post('post',['middleware' => 'throttle:5','uses' => 'PostController@store']) // middleware eklememizin sebebi, art arda sunucu istekleini engellemek
});
<?php
namespace App\Http\Controllers;
use App\Http\Requests\Post as Request;
use App\Http\Controllers\Controller;
class PostController extends Controller
{
public function index(){
<?php
namespace App\Http\Requests;
use App\Http\Requests\Request;
class Post extends Request
{
/**
* Determine if the user is authorized to make this request.
<!doctype html>
<html lang="tr">
<head>
<meta charset="UTF-8">
<meta name="author" content="Ferdi ÜNAL">
<meta name="_token" content="{!! csrf_token() !!}">
<title>Post</title>
</head>
<body>
@ferdiunal
ferdiunal / post.js
Last active April 16, 2016 15:28
Laravel ile ajax işlemi
/**
* index.blade.php'de jQuery'nin yüklü olması gerekiyor.
* index.blade.php'de head tagları arasına
* <meta name="_token" content="{!! csrf_token !!}" /> 'i ekliyoruz
*/
$.ajaxSetup({
// Ajax Post işlemi sırasında Laravel'in TokenMismatchException hatası vermemesi için
'datatype' :'json',
'method' : 'post',
@ferdiunal
ferdiunal / kernel.php
Created April 25, 2016 20:56
Kernel.php
<?php
namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
{
/**
* The application's global HTTP middleware stack.
<?php
namespace Bootstrap;
class Application extends Illuminate\Foundation\Application
{
/**
* The Laravel framework version.
*
* @var string
*/
@ferdiunal
ferdiunal / Application.php
Created June 11, 2016 19:31
Laravel Custom Directory
<?php
namespace Lib;
use Illuminate\Foundation\Application as Laravel;
/**
* @name Ferdi ÜNAL
* @email ferdi@unal.pw
*/
class Application extends Laravel
{
<?php
/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| The first thing we will do is create a new Laravel application instance
| which serves as the "glue" for all the components of Laravel, and is
| the IoC container for the system binding all of the various parts.
@ferdiunal
ferdiunal / routes.php
Last active June 22, 2016 09:12
Laravel'de farklı dizindeki dosyaları kendi oluşturduğumuz url'ler ile nasıl göstereceğimizi aşağıda belirttim. $path değişkeni sizin dosyanızın yolunu belirler.
<?php
/***
* Laravel'de farklı dizindeki dosyaları kendi oluşturduğumuz url'ler ile
* nasıl göstereceğimizi aşağıda belirttim.
* $path değişkeni sizin dosyanızın yolunu belirler.
*/
Route::get('/img/{user_id}/{filename}',function($userId,$filename){
$path = public_path("upload/users/{$userId}/{$filename}");
if(!\File::isFile($path)){
abort(404,"Dosya bulunamadı !");