Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3400f00
commit 8fbee84
Showing
10 changed files
with
163 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
namespace App\View\Components; | ||
|
||
use App\Abstracts\View\Component; | ||
use App\Utilities\Versions; | ||
use Illuminate\Support\Arr; | ||
|
||
class UpdateAlert extends Component | ||
{ | ||
public $alerts; | ||
|
||
/** | ||
* Create a new component instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct(array $alerts = []) | ||
{ | ||
$this->alerts = $this->getAlerts($alerts); | ||
} | ||
|
||
/** | ||
* Get the view / contents that represent the component. | ||
* | ||
* @return \Illuminate\Contracts\View\View|string | ||
*/ | ||
public function render() | ||
{ | ||
return view('components.update-alert'); | ||
} | ||
|
||
public function getAlerts() | ||
{ | ||
$alerts = []; | ||
|
||
$updates = Versions::getUpdates(); | ||
|
||
if (! $updates) { | ||
return $alerts; | ||
} | ||
|
||
foreach ($updates as $alias => $update) { | ||
if (! $update->errors) { | ||
continue; | ||
} | ||
|
||
foreach ($update->errors as $key => $error) { | ||
switch ($key) { | ||
case 'core': | ||
$type = 'danger'; | ||
break; | ||
case 'expires': | ||
case 'compatible': | ||
$type = 'warning'; | ||
break; | ||
default: | ||
$type = 'danger'; | ||
} | ||
|
||
if (is_object($error) || is_array($error)) { | ||
foreach ($error as $message) { | ||
$alerts[$type][] = $message; | ||
} | ||
} else { | ||
$alerts[$type][] = $error; | ||
} | ||
} | ||
} | ||
|
||
return $alerts; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@foreach ($alerts as $type => $messages) | ||
@foreach ($messages as $message) | ||
<x-alert :type="$type" :message="$message" /> | ||
@endforeach | ||
@endforeach |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters