Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #717 from TheRestartProject/RES-1964_customisable_…
…banners RES-1964 customisable banners
- Loading branch information
Showing
23 changed files
with
839 additions
and
111 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace App; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use DB; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Support\Facades\Lang; | ||
use Illuminate\Support\Facades\Log; | ||
use OwenIt\Auditing\Contracts\Auditable; | ||
|
||
class Alert extends Model implements Auditable | ||
{ | ||
use HasFactory; | ||
|
||
use \OwenIt\Auditing\Auditable; | ||
|
||
protected $table = 'alerts'; | ||
protected $primaryKey = 'id'; | ||
|
||
/** | ||
* The attributes that are mass assignable. | ||
* | ||
* @var array | ||
*/ | ||
protected $fillable = [ | ||
'title', | ||
'html', | ||
'ctatitle', | ||
'ctalink', | ||
'start', | ||
'end', | ||
'variant' | ||
]; | ||
} |
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,77 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use App\User; | ||
use Illuminate\Console\Command; | ||
use Illuminate\Support\Str; | ||
|
||
use function Symfony\Component\VarDumper\Dumper\esc; | ||
|
||
class AlertCreate extends Command | ||
{ | ||
/** | ||
* Example: php artisan alert:create 'Test alert' '<p>Testing</p>' 'today' 'next year' 'Click here' 'https://therestartproject.org' | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'alert:create {title} {html} {start} {end} {variant?} {ctatitle?} {ctalink?}'; | ||
|
||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Create a system-wide alert'; | ||
|
||
/** | ||
* Create a new command instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
} | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return mixed | ||
*/ | ||
public function handle() | ||
{ | ||
$title = trim($this->argument('title')); | ||
$html = trim($this->argument('html')); | ||
$ctatitle = trim($this->argument('ctatitle')); | ||
$ctalink = trim($this->argument('ctalink')); | ||
$start = trim($this->argument('start')); | ||
$end = trim($this->argument('end')); | ||
$variant = trim($this->argument('variant')); | ||
$variant = $variant ? $variant : 'secondary'; | ||
|
||
$alert = new \App\Alert(); | ||
$alert->title = $title; | ||
$alert->html = $html; | ||
$alert->variant = $variant; | ||
|
||
if ($ctatitle && $ctalink) { | ||
$alert->ctatitle = $ctatitle; | ||
$alert->ctalink = $ctalink; | ||
} | ||
|
||
// Parse $start as a date and set it in the alert. | ||
$start = \Carbon\Carbon::parse($start); | ||
$start->setTimezone('UTC'); | ||
$end = \Carbon\Carbon::parse($end); | ||
$end->setTimezone('UTC'); | ||
|
||
$alert->start = $start; | ||
$alert->end = $end; | ||
|
||
$alert->save(); | ||
|
||
$this->info("Created alert " . $alert->id); | ||
} | ||
} |
Oops, something went wrong.