인기있는 tricks

로그인한 후 리다이렉트 되는 URL 변경하기
Laravel은 로그인이 성공한 뒤 /home 으로 라다이렉트한다. 이를 다른 URL로 변경하려면 AuthController에 $redirectPath 속성을 추가해서 지정하면 된다. App\Http\Controllers\Auth\AuthController namespace…
Submitted 8 years ago in Security
4126
0
0
5.1
blade의 @endsection 과 @stop 의 차이점
@section('content') @stop blade의 섹션을 닫을 때, Laravel 3에서는 @endsection, Laravel 4에서는 @stop으로 바뀐 걸로 알고 있었는데, Laravel 5 예제 소스들에서 @endsection이 보여서 둘 간의 차이점을 찾아봤다.…
Submitted 8 years ago in Views, Template
4082
0
0
updated_at 컬럼 사용하지 않기
Laravel Eloquent는 timestamp 컬럼인 created_at, updated_at 에 대해서 자동으로 날짜를 설정하고, 갱신하는 작업을 수행하다. 이 중 created_at 컬럼은 사용하고, updated_at 컬럼은 사용하지 않을 경우에는…
Submitted 8 years ago in Eloquent
3992
0
0
URL과 쿼리스트링 구하기
http://example.com/test?foo=bar url() // http://example.com Request::getPathInfo() // /test Request::url() // http://example.com/test Request::fullurl() // http://example.com/test?foo=bar Request::getQueryString() // foo=bar
Submitted 8 years ago in Request and Input
3926
0
0
날짜를 몇시간 전, 며칠 전 형태로 표시하기
페이스북이나 트위터 등의 타임라인에서는 보통 등록시간을 몇분 전, 며칠 전 같은 형태로 표시를 한다. Laravel에서는 Carbon 클래스를 사용하면 쉽게 구현할 수 있다.
Submitted 10 years ago in Helper
3904
0
0
Laravel 프레임웍 없이 Eloquent 사용하기
Laravel 프레임을 사용하지 않더라도 Eloquent ORM을 사용할 수가 있다. eloquent 설치 $ composer require illuminate/database database.php 파일 생성 <?php require 'vendor/autoload.php'; use Illuminate\Database\Capsule\Manager as…
Submitted 10 years ago in Eloquent
3834
0
0
1픽셀 투명이미지 출력하기
별도의 이미지 파일을 두지 않고 (IO를 줄이기 위해서) 가로, 세로 1 픽셀짜리 투명 이미지를 출력하는 방법 $img =…
Submitted 10 years ago in Performance
3806
0
0
최적화 명령어들
최적화 명령어들 php artisan optimize php artisan config:cache php artisan route:cache 최적화 명령어로 생성된 캐시 삭제 명령어들 php artisan clear-compiled php artisan config:clear php artisan route:clear php artisan view:clear…
Submitted 8 years ago in Performance
3795
0
0
다중 환경 설정하기
개발, 스테이징, 서비스 등 Laravel 동작 환경을 여러 개로 나누고 각각의 환경에 맞게 설정을 따로 가져가는 방법을 알아보자. 1. 환경변수를 이용하는 방법 bootstrap/start.php 파일에서 환경…
Submitted 10 years ago in Configuration
3733
0
0
리소스 네이밍 규칙
네이밍은 규칙 정하기 나름이지만 다음과 같이 정하면 어떨까 한다. Model만 단수형을 사용하고, DB Table, Controller, Route, View 등은 복수형을 사용한다. 예) Task Model : Task DB Table : tasks Controller :…
Submitted 10 years ago in Configuration
3655
0
0
특정 라우팅은 HTTPS 만 가능하게 하기
특정 요청은 무조건 https로만 접근하게 하고자 할 때, http로 접속한 경우 https로 리다이렉트 하도록 하기 위해서 다음의 Middleware를 사용하면 된다. app/Http/Middleware/ForceHttps.php <?php namespace…
Submitted 8 years ago in Routing
3646
0
0
PasswordBroker 오버라이딩하기
비밀번호 리셋에 관련된 로직은 Illuminate\Auth\Passwords\PasswordBroker 클래스에서 수행이 되는데, 이 로직을 변경하고자 한다면 다음의 방법을 사용하면 된다. CustomPassowordBroker 생성…
Submitted 8 years ago in Security
3539
0
0
5.1
스키마 빌더에서 컬럼 주석 사용하기
스키마 작성시 comment 메서드를 사용하면 컬럼에 주석을 달 수 있다. public function up() { Schema::create('posts', function(Blueprint $table) { $table->increments('id')->comment('Unique identifier');…
Submitted 8 years ago in Migration
3523
0
0
timestamps 컬럼명 지정하기
timestamps를 사용하는 경우 (default) created_at, updated_at, deleted_at 컬럼명이 기본인데, 다음의 방법으로 이를 변경할 수 있다. 방법 1 User extends Eloquent{ const CREATED_AT = 'registered_at'; const UPDATED_AT =…
Submitted 10 years ago in Eloquent
3366
0
0
다운타임없이 Laravel 4.1.26으로 업그레이드 하기
인증시 사용되는 remember me 쿠키에 보안 문제가 생겨서 Larvel 4.1.26이 릴리즈 됐습니다. Laravel 4.1.26을 업그레이드를 하려면 패키지는 물론 User.php와 users DB 테이블을 변경해야 한다. 다음의…
Submitted 10 years ago in Configuration
3345
0
1