Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <input type="date" id="expiry_date" class="form-control @error('expiry_date') is-invalid @enderror" name="expiry_date" value="{{ old('expiry_date') }}" required autocomplete="expiry_date">
- public function import()
- {
- Excel::import(new excel_import(), storage_path('excel_file.xlsx'));
- return redirect()->route('index');
- }
- public function model(array $row)
- {
- try
- {
- $date = Carbon::createFromFormat("d.m.Y", $row[5])->format('Y-m-d');
- //$timestamp = strtotime($row[5]);
- //$date = date("Y-m-d", $timestamp);
- return new Item([
- 'user' => $row[0],
- 'name' => $row[1],
- 'expiry_date' => $date,
- ]);
- }
- catch(Throwable $t){
- return null;
- }
- }
- public $casts = ['expiry_date' => 'date:Y-m-d',];
- public $dates = ['expiry_date',];
- $table->date('expiry_date')->nullable();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement