0

How to assign an input value to variable in plugins bacckend form.

$termid = Input::get('term_id'); // this code doesn't work for me.

namespace Cng\Tennis\Models;
use Model;
use Flash;
use Db;
use Input;

class Lesson extends Model {

    public function getSdateOptions () {

            // $attributes = $this->getAttributes();
            // $termid = $attributes['term_id'];

            $termid = Input::get('term_id');

        if ($this->term_id == $termid ) {
            $term = Db::table('cng_tennis_term')->where('id', $termid )->first();
            return [  $term->start_date =>  $term->finish_date ]; 
        }
        else {
            return ['Select a date' => 'Select a date' ];
            } 
        }
Dapk
  • 203
  • 2
  • 10

1 Answers1

0

try this :

namespace Cng\Tennis\Models;
use Model;
use Flash;
use Db;
use Input;

class Lesson extends Model {

    public static function getSdateOptions ($term_id = null) {
        if(!$term_id){return false;}
            // $attributes = $this->getAttributes();
            // $termid = $attributes['term_id'];

        if ($this->term_id == $termid ) {
            $term = Db::table('cng_tennis_term')->where('id', $termid )->first();
            return [  $term->start_date =>  $term->finish_date ]; 
        }
        else {
            return ['Select a date' => 'Select a date' ];
            } 
        }

and in your controller or components

 $result = Lesson::getSdateOptions(Input::get('term_id'));

i hope help you

Mohammad
  • 652
  • 1
  • 7
  • 18