2022-03-14 19:13:10 +01:00
|
|
|
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
|
2024-04-07 22:27:36 +02:00
|
|
|
use App\Models\BaseModel;
|
2022-03-14 19:13:10 +01:00
|
|
|
|
2024-04-07 22:27:36 +02:00
|
|
|
class TracksModel extends BaseModel
|
2022-03-14 19:13:10 +01:00
|
|
|
{
|
2024-04-07 22:27:36 +02:00
|
|
|
protected $table = 'tracks';
|
2022-03-14 19:13:10 +01:00
|
|
|
protected $db;
|
2024-04-07 22:27:36 +02:00
|
|
|
protected $allowedFields = ['id', 'name', 'img', 'category', 'author', 'description'];
|
2022-03-14 19:13:10 +01:00
|
|
|
|
2024-04-07 22:27:36 +02:00
|
|
|
/*
|
|
|
|
public function __construct($track=null)
|
2022-03-14 19:13:10 +01:00
|
|
|
{
|
2024-04-07 22:27:36 +02:00
|
|
|
if ($track) $this->import($track);
|
2022-03-14 19:13:10 +01:00
|
|
|
}
|
|
|
|
|
2024-04-07 22:27:36 +02:00
|
|
|
public function import($properties)
|
|
|
|
{
|
|
|
|
foreach($properties as $key => $value) $this->{$key} = $value;
|
2022-03-14 19:13:10 +01:00
|
|
|
}
|
2024-04-07 22:27:36 +02:00
|
|
|
|
|
|
|
public function getLink($text='')
|
|
|
|
{
|
2022-03-14 19:13:10 +01:00
|
|
|
if($text == '') $text = $this->username;
|
|
|
|
return '<a href="track/'.$this->id.'">'.$text.'</a>';
|
|
|
|
}
|
2024-04-07 22:27:36 +02:00
|
|
|
|
|
|
|
public function card($text='')
|
|
|
|
{
|
2022-03-14 19:13:10 +01:00
|
|
|
return $this->name.$this->img;
|
|
|
|
}
|
2024-04-07 22:27:36 +02:00
|
|
|
|
2022-03-14 19:13:10 +01:00
|
|
|
public function imgTag() {
|
|
|
|
return "<img width='80' src='". base_url() ."/".$this->img."' alt='".$this->name."' title='".$this->name."'>";
|
|
|
|
}
|
2024-04-07 22:27:36 +02:00
|
|
|
|
2022-03-14 19:13:10 +01:00
|
|
|
public function imgTagFull() {
|
|
|
|
return "<img src='". base_url() ."/".$this->img."' class='track-img' alt='".$this->name."'>";
|
|
|
|
}
|
|
|
|
public function clickableName() {
|
|
|
|
return $this->linkTag($this->name);
|
|
|
|
|
|
|
|
}
|
|
|
|
public function clickableImgTag() {
|
|
|
|
return $this->linkTag($this->imgTag());
|
|
|
|
}
|
|
|
|
public function linkTag($content) {
|
|
|
|
return "<a href='". base_url() ."/track/".$this->id."'>".$content."</a>";
|
|
|
|
}
|
|
|
|
|
|
|
|
public function linkTitleImgTag()
|
|
|
|
{
|
|
|
|
$content = $this->name . '<br />' . $this->imgTag();
|
|
|
|
return "<a href='" . base_url() . "/track/{$this->id}'>$content</a>";
|
|
|
|
}
|
2024-04-07 22:27:36 +02:00
|
|
|
*/
|
2022-03-14 19:13:10 +01:00
|
|
|
}
|