forked from corowne/lorekeeper
-
Notifications
You must be signed in to change notification settings - Fork 2
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
bab2d2f
commit 4fe01ae
Showing
25 changed files
with
546 additions
and
155 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
namespace App\Models\Character; | ||
|
||
use App\Models\Model; | ||
|
||
class CharacterImageTitle extends Model { | ||
/** | ||
* The attributes that are mass assignable. | ||
* | ||
* @var array | ||
*/ | ||
protected $fillable = [ | ||
'character_image_id', 'title_id', 'data', | ||
]; | ||
|
||
/** | ||
* The table associated with the model. | ||
* | ||
* @var string | ||
*/ | ||
protected $table = 'character_image_titles'; | ||
|
||
/** | ||
* The attributes that should be cast to native types. | ||
* | ||
* @var array | ||
*/ | ||
protected $casts = [ | ||
'data' => 'array', | ||
]; | ||
|
||
/********************************************************************************************** | ||
RELATIONS | ||
**********************************************************************************************/ | ||
|
||
/** | ||
* Get the character image. | ||
*/ | ||
public function image() { | ||
return $this->belongsTo(CharacterImage::class, 'character_image_id'); | ||
} | ||
|
||
/** | ||
* Get the title. | ||
*/ | ||
public function title() { | ||
return $this->belongsTo(CharacterTitle::class, 'title_id'); | ||
} | ||
|
||
/********************************************************************************************** | ||
ATTRIBUTES | ||
**********************************************************************************************/ | ||
|
||
/** | ||
* Displays the title. | ||
* | ||
* @return string | ||
*/ | ||
public function getDisplayTitleAttribute() { | ||
if ($this->title_id) { | ||
return $this->title->displayTitle($this->data); | ||
} | ||
|
||
return '<div><span class="badge ml-1" style="color: white; background-color: #ddd;">'.isset($this->data['short']) ?? $this->data['full'].'</span></div>'; | ||
} | ||
} |
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
Oops, something went wrong.