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
<?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 | |
}); |
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
<?php | |
namespace App\Http\Controllers; | |
use App\Http\Requests\Post as Request; | |
use App\Http\Controllers\Controller; | |
class PostController extends Controller | |
{ | |
public function index(){ |
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
<?php | |
namespace App\Http\Requests; | |
use App\Http\Requests\Request; | |
class Post extends Request | |
{ | |
/** | |
* Determine if the user is authorized to make this request. |
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
<!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> |
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
/** | |
* 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', |
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
<?php | |
namespace App\Http; | |
use Illuminate\Foundation\Http\Kernel as HttpKernel; | |
class Kernel extends HttpKernel | |
{ | |
/** | |
* The application's global HTTP middleware stack. |
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
<?php | |
namespace Bootstrap; | |
class Application extends Illuminate\Foundation\Application | |
{ | |
/** | |
* The Laravel framework version. | |
* | |
* @var string | |
*/ |
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
<?php | |
namespace Lib; | |
use Illuminate\Foundation\Application as Laravel; | |
/** | |
* @name Ferdi ÜNAL | |
* @email ferdi@unal.pw | |
*/ | |
class Application extends Laravel | |
{ |
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
<?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. |
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
<?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ı !"); |