laravel에서 작동하지 않는 Eloquent create

Mh 쇼헬

저는 laravel을 처음 사용하여 게시물을 작성하는 데 문제가 있습니다.

내 경로는 다음과 같습니다.

Route::post('savepost', 'PostsController@savepost');

여기 내 createpost.blade.php가 있습니다.

@include('header')

  <div class="container">

      <!-- Main component for a primary marketing message or call to action -->
      <div class="jumbotron">
        <h3>Create New Post</h3>

            <form action="savepost" class="form-horizontal" method="post" role="form">
              <div class="form-group">
                <label for="inputEmail3" class="col-sm-4 control-label">Post Title</label>
                <div class="col-sm-8">
                  <input type="text" class="form-control" name="title" id="inputEmail3" placeholder="Enter New Title">
                </div>
                @if($errors->has('title'))
                    <p class="alert alert-danger"><strong>oopps! </strong>{{ $errors->first('title') }} </p>
                @endif
              </div>
              <div class="form-group">
                <label for="inputPassword3" class="col-sm-4 control-label">Post Description</label>
                <div class="col-sm-8">
                  <textarea name="description"></textarea>
                </div>

                @if($errors->has('description'))
                    <p class="alert alert-danger"><strong>oopps! </strong>{{ $errors->first('description') }} </p>
                @endif

              </div>

              <div class="form-group">
                <div class="col-sm-offset-2 col-sm-8">
                  <input type="submit" class="btn btn-default" value="Save Post">
                </div>

              </div>
            </form>

      </div>

    </div> <!-- /container -->

@include('footer')

다음은 내 PostsController입니다.

class PostsController extends BaseController{

    public function createpost(){
        return View::make('createpost');
    }   


    public function savepost(){

        $input = Input::all();
        $validation = Validator::make($input, Posts::$rules);

        if ($validation->passes())
        {


        Posts::create(array(
            'title'=>Input::get('title'),
            'description'=>Input::get('description')
        ));

        }
        else{
        return Redirect::route('createpost')->withErrors($validation);
        }

    }

}

내 모델은 다음과 같습니다.

class Posts extends Eloquent {

protected $guarded = array();
protected $fillable = array('name', 'description');


    protected $table = 'posts';

    public static $rules = array(
        'title' => 'required|min:5',
        'description' => 'required'
    );
}

그리고 여기 내 게시물 데이터베이스가 있습니다.

id    title   description   url   date

제발 도와주세요

아담

게시물 테이블에 기본 라벨 타임 스탬프가 없습니다. 다음을 수행하여 모델에서이를 해제하십시오.

public $timestamps = false;

또는 게시물 테이블에 추가하십시오.

alter table posts add created_at datetime NOT NULL
alter table posts add updated_at datetime

또는 모델에서 고유 한 타임 스탬프를 만듭니다. 날짜 열이 있으므로 다음과 같이 할 수 있습니다.

const CREATED_AT = 'date';

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

Laravel의 Eloquent ORM에서 작동하지 않는 getPaginationCount () 함수

Laravel eloquent에서 조건이 작동하지 않는 배수

Laravel에서 작동하지 않는 Eloquent 쿼리

Laravel Eloquent with () 메서드는 'where'에서는 작동하지만 'Model :: find ()'에서는 작동하지 않습니다.

Laravel isNotEmpty()가 Eloquent 모델에서 작동하지 않습니다

Laravel Orderby가 Eloquent에서 작동하지 않습니다.

whereHas 및 whereDoesntHave는 laravel eloquent에서 예상대로 작동하지 않습니다.

동적 절이 작동하지 않는 Laravel Eloquent 쿼리

Laravel Eloquent 또는 예상대로 작동하지 않는 곳

Laravel Eloquent는 의도 한대로 작동하지 않습니다.

Laravel Eloquent는 작동하지 않습니다.

Laravel 5 관계에서 Eloquent 검색이 작동하지 않습니다.

laravel eloquent의 다 대다 relationschop은 pluck ()에서 작동하지 않습니다.

Eloquent toArray는 하위 쿼리에서 작동하지 않습니다

Laravel : 날짜가 Model :: create ()에서 작동하지 않습니까?

Eloquent 쿼리는 별도로 작동하지만 하위 쿼리에서 함께 작동하지 않습니다.

Laravel eloquent mutator는 업데이트 데이터에서 작동하지 않습니다.

Laravel Eloquent : 다중 단어 테이블 이름에서 작동하지 않는 경로 모델 바인딩

업데이트 또는 파괴 방법이 laravel eloquent 모델에서 작동하지 않습니까?

Laravel Eloquent-take (n)은 작동하지만 limit (n)은 작동하지 않는 이유는 무엇입니까?

Laravel Eloquent ORM 쿼리가 작동하지 않음 Laravel v6.9

Laravel Eloquent 컬렉션이 예상대로 작동하지 않는 경우

Grails 3.1.3에서 작동하지 않는 grails create-app

WebStorm에서 작동하지 않는 "create-react-app"디버깅

create-react-app에서 작동하지 않는 sass

create-react-app nginx에서 작동하지 않는 도메인

Laravel Eloquent 속성 캐스팅이 작동하지 않습니다.

Laravel Eloquent 정의 관계가 작동하지 않습니다

Laravel 5.1 Eloquent 관계 Eager 로딩이 작동하지 않음

TOP 리스트

  1. 1

    C # 16 진수 값 0x12는 잘못된 문자입니다.

  2. 2

    Matlab의 반복 Sortino 비율

  3. 3

    librosa로 생성 된 스펙트로 그램을 다시 오디오로 변환 할 수 있습니까?

  4. 4

    PhpStorm 중단 점에서 변수 값을 볼 수 없습니다.

  5. 5

    종속 사용자 정의 Lightning 선택 목록 Level2 및 Level3을 설정한 다음 Lightning 구성 요소에서 Level2를 재설정하지만 Level2 캐시 데이터가 저장됨

  6. 6

    Watchdog 큐 이벤트를 사용하는 Python 병렬 스레드

  7. 7

    atob은 인코딩 된 base64 문자열을 디코딩하지 않습니다.

  8. 8

    dev 브랜치에 병합 할 때만 트리거하도록 bitbucket에서 AWS Codebuild로 웹훅을 설정하려면 어떻게해야합니까?

  9. 9

    2 개의 이미지를 단일 평면 이미지로 결합

  10. 10

    Assets의 BitmapFactory.decodeStream이 Android 7에서 null을 반환합니다.

  11. 11

    막대 그래프 위에 선이 표시되지 않음

  12. 12

    Python : 특정 범위를 초과하면 플롯의 선 색상을 변경할 수 있습니까?

  13. 13

    기능 선택을위한 Sklearn Chi2

  14. 14

    Ionic 2 로더가 적시에 표시되지 않음

  15. 15

    EventEmitter <string>의 컨텍스트 'this'가 Observable <string> 유형의 'this'메서드에 할당되지 않았습니다.

  16. 16

    매개 변수에서 쿼리 객체를 선언하는 방법은 무엇입니까?

  17. 17

    openCV python을 사용하여 텍스트 문서에서 워터 마크를 제거하는 방법은 무엇입니까?

  18. 18

    아이디어 Intellij : 종속성 org.json : json : 20180813을 찾을 수 없음, maven에서 org.json 라이브러리를 가져올 수 없음

  19. 19

    일반 메서드에서 클래스 속성에 액세스하는 방법-C #

  20. 20

    식별자는 ORA-06550 및 PLS-00201로 선언되어야합니다.

  21. 21

    함수 호출 사이에 데이터를 저장하는 파이썬적인 방법은 무엇입니까?

뜨겁다태그

보관