|
3 | 3 | namespace Rappasoft\LaravelLivewireTables\Views\Columns; |
4 | 4 |
|
5 | 5 | use Carbon\Carbon; |
6 | | -use DateTime; |
7 | 6 | use Carbon\Exceptions\InvalidFormatException; |
| 7 | +use DateTime; |
8 | 8 | use Illuminate\Database\Eloquent\Model; |
9 | 9 | use Illuminate\Support\HtmlString; |
10 | 10 | use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException; |
@@ -37,36 +37,26 @@ public function getContents(Model $row): null|string|\BackedEnum|HtmlString|Data |
37 | 37 | return $dateTime->format($this->getOutputFormat()); |
38 | 38 | } else { |
39 | 39 | // Check if format matches what is expected and return Carbon instance if so, otherwise emptyValue |
40 | | - if (Carbon::canBeCreatedFromFormat($dateTime, $this->getInputFormat())) |
41 | | - { |
| 40 | + if (Carbon::canBeCreatedFromFormat($dateTime, $this->getInputFormat())) { |
42 | 41 | return Carbon::createFromFormat($this->getInputFormat(), $dateTime)->format($this->getOutputFormat()); |
43 | | - } |
44 | | - else |
45 | | - { |
| 42 | + } else { |
46 | 43 | try { |
47 | | - if ($date = Carbon::parse($dateTime)) |
48 | | - { |
| 44 | + if ($date = Carbon::parse($dateTime)) { |
49 | 45 | return $date->format($this->getOutputFormat()); |
50 | | - } |
51 | | - } |
52 | | - catch (InvalidFormatException $e) |
53 | | - { |
| 46 | + } |
| 47 | + } catch (InvalidFormatException $e) { |
54 | 48 | return $this->getEmptyValue(); |
55 | | - } |
56 | | - catch (\Exception $e) |
57 | | - { |
| 49 | + } catch (\Exception $e) { |
58 | 50 | return $this->getEmptyValue(); |
59 | 51 | } |
60 | 52 | } |
| 53 | + |
61 | 54 | return $this->getEmptyValue(); |
62 | 55 | } |
63 | 56 | } |
64 | | - } |
65 | | - catch (InvalidFormatException $e) |
66 | | - { |
| 57 | + } catch (InvalidFormatException $e) { |
67 | 58 | return $this->getEmptyValue(); |
68 | | - } |
69 | | - catch (\Exception $exception) { |
| 59 | + } catch (\Exception $exception) { |
70 | 60 | return $this->getEmptyValue(); |
71 | 61 | } |
72 | 62 |
|
|
0 commit comments