1

i have basic like this

 public function store(Request $request)
 {
    $input = Input::all();


    $schedule = new Schedule;
    $student->name = $input['name'];
    $student->for_date = $input['for_date'];
    $student->save();
    return view('students.index');
}

My plan is ' what if I want to include the same students and for_date for today and the next day'

may be like this,..

-------------------
|name | for_date  |
-------------------
|eka  | 2016-09-04|
|eka  | 2016-09-05|
|eka  | 2016-09-06|
|eka  | 2016-09-07|

anyone have any suggestions? please, thank you

1 Answer 1

1

frontend post array datas, then just use foreach.

public function store(Request $request)
{
    $inputArrays = Input::all();
    $schedule = new Schedule;
    foreach ($inputArrays as $array) {
        $student->name = $name;
        $student->for_date = $date;
        $student->save();
    }
    return view('students.index');
}
Sign up to request clarification or add additional context in comments.

3 Comments

if at the front end just put 1 data only, but of the controller will make the data array, whether it possibly be? btw, thanks
@yes, you can serialize datas from frontend then unserialize it at backend.or just use join('|') from frontend then explode('|', datas) from backend
@ekaputra, if this is useful for you , please take my answer , then both of us can get reputations

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.