title: Need to solve undefined index error in laravel 5
body: <p>I am trying to schedule posts to a FB Page with laravel 5 and facebook SDK.</p>
  
  <p>I need to choose between post a comment <strong>now</strong> or schedule it for later.</p>
  
  <p>With my code bellow I am able to schedule my post. But if I want to post immediately an exception is thrown:</p>
  
  <blockquote>
    <p>"ErrorException in FacebookController.php line 118: Undefined index: pub_schedule". Line 118 is "if ($input['pub_schedule'] !=1)"</p>
  </blockquote>
  
  <p>What's wrong here?</p>
  
  <h3>This is my Form:</h3>
  
  <pre><code>&lt;div class="form-group"&gt;
            &lt;label class="col-sm-4 control-label"&gt;Veröffentlichen auf&lt;/label&gt;
            &lt;div class="col-sm-8"&gt;
                {!! Form::label('pub_facebook', 'Facebook') !!}
                {!! Form::checkbox('pub_facebook') !!}
  
                {!! Form::label('pub_website', 'Meiner Webseite') !!}
                {!! Form::checkbox('pub_website') !!}
  
            &lt;/div&gt;
        &lt;/div&gt;
  
        &lt;div class="form-group"&gt;
            &lt;label class="col-sm-4 control-label"&gt;Veröffentlichen am&lt;/label&gt;
            &lt;div class="col-sm-8"&gt;
  
              {!! Form::label('pub_now', 'Sofort Veröffentlichen') !!}
              {!! Form::checkbox('pub_now') !!}
  
              {!! Form::label('pub_schedule', 'Für Später Planen') !!}
              {!! Form::checkbox('pub_schedule') !!}
            &lt;/div&gt;
        &lt;/div&gt;
  
        &lt;div class="form-group"&gt;
          {!! Form::label('published_at', 'Veröffentlichungsdatum') !!}
          {!! Form::input('datetime','published_at', Carbon\Carbon::now()-&gt;format('Y-m-d H:i'), ['class' =&gt; 'form-control']) !!}
        &lt;/div&gt;
  </code></pre>
  
  <h3>This Is my ArticlesController:</h3>
  
  <pre><code>public function store(ArticleRequest $request) {
  
  
    // Only if the user is a FB user then this function will execute.
    if(Auth::user()-&gt;facebook_user_id != 0)
    {
      //Checkbox Publish on FB
      if($request-&gt;pub_facebook !=0) {
        //Radio Button Schedule
        if ($request-&gt;pub_schedule!=0) {
          if(strtotime($request-&gt;get('published_at')) &lt; strtotime("+11 minutes") ){
            // send a message to user to change the scheduled time.
            return 'Please schedule you post again: +11 Minutes';
          }
        } else {
          $graphNode = FacebookController::postToFBPage($request-&gt;all());
        }
      }
    }
  </code></pre>
  
  <h3>This is My FacebookController:</h3>
  
  <pre><code>public static function postToFBPage($input, $page_id = '')
  {
  
      $page_id == '' ? $page_id = '' : $page_id;
  
      // Creating a new FB object.
      $fb = new \Facebook\Facebook([
          'app_id' =&gt; env('FACEBOOK_APP_ID'),
          'app_secret' =&gt; env('FACEBOOK_APP_SECRET'),
          'default_graph_version' =&gt; env('FACEBOOK_GRAPH_VERSION'),
          ]);
  
  
    // Sample and some of the possible fields that can be send when posting to FB.
    // $linkData = [
    //   'link' =&gt; 'absolute link here',
    //   'message' =&gt; 'Main body content here',
    //   'picture' =&gt; 'path/to/the/image.jpg'
    //   ];
  
  
    //to post immediately
  
    if ($input['pub_schedule'] !=1) {
      $linkData = [
      'message' =&gt; $input['title'] . "\n" . $input['body'] . "\n" . $input['price']
      ];
  
     // to schedule a post to fb
    } else {
      $linkData = [
      'message' =&gt; $input['title'] . "\n" . $input['body'] . "\n" . $input['price'] ,
        "published" =&gt; false,
        'scheduled_publish_time' =&gt; strtotime($input['published_at']),
      ];
    }
  </code></pre>