Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. <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">
  2.  
  3. public function import()
  4. {
  5. Excel::import(new excel_import(), storage_path('excel_file.xlsx'));
  6. return redirect()->route('index');
  7. }
  8.  
  9. public function model(array $row)
  10. {
  11. try
  12. {
  13. $date = Carbon::createFromFormat("d.m.Y", $row[5])->format('Y-m-d');
  14. //$timestamp = strtotime($row[5]);
  15. //$date = date("Y-m-d", $timestamp);
  16. return new Item([
  17. 'user' => $row[0],
  18. 'name' => $row[1],
  19. 'expiry_date' => $date,
  20.  
  21. ]);
  22. }
  23. catch(Throwable $t){
  24. return null;
  25. }
  26. }
  27.  
  28. public $casts = ['expiry_date' => 'date:Y-m-d',];
  29. public $dates = ['expiry_date',];
  30.  
  31. $table->date('expiry_date')->nullable();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement