A lot of assumptions made here so adjust your code accordingly. If you don't understand something please leave a comment.
Before you store anything you need to have a route which your form will post the data to, you could do something like this for example:
routes.php
Route::post('report', [
'uses' => 'ReportsController@store'
]);
ReportsController.php
public function store(Request $request)
{
// date should be the name of your input in your form,
// i.e. whatever is in the "name" attribute
$dateInput = $request->get('date');
// or you could do $dateInput = \Input::get('date') if you're not injecting Illuminate\Http\Request
$date = explode('-', $dateInput);
$year = $date[0];
$month = $date[1];
// I am assuming your model is named Report and you're using Eloquent
\Report::create([
'month' => $month,
'year' => $year
]);
// finished so do something here
return redirect()->back();
}
EDIT: to deal with multiple date fields
Update html in view as so:
<!-- with the name value followed by [] it will pass value as an array, you can have as many of these as you like -->
<input name="date[]" data-month="month-' + meta.row + '" class="form-control month" type="month" />
<input name="date[]" data-month="month-' + meta.row + '" class="form-control month" type="month" />
<input name="date[]" data-month="month-' + meta.row + '" class="form-control month" type="month" />
Controller method
$dateInputs = $request->get('date'); // get the date input array
$reports = []; // this will keep what we input in our DB
// loop through the date input array
foreach($dateInputs as $dateInput)
{
$date = explode('-', $dateInput);
$year = $date[0];
$month = $date[1];
$reports[] = \Report::create([
'month' => $month,
'year' => $year
]);
}
return $reports; // this is what has been input! YAY!
Important point: In the question you said you were looking for a solution for splitting the string from Laravel - now Laravel does provide a lot of helper methods as part of the framework and some of them are even for string manipulation, but I believe this is the wrong way of approaching your issue. You definitely should be looking at how PHP can help you do this as it's a pretty trivial issue and not something you would require a framework for, so please note that the explode method is a method as part of the PHP programming language and not Laravel. Perhaps you can do some research into why someone would use a framework to better understand the point I'm making.
Hope that helps!