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 CarsModel extends BaseModel
|
2022-03-14 19:13:10 +01:00
|
|
|
{
|
2024-04-07 22:27:36 +02:00
|
|
|
private $data;
|
|
|
|
|
|
|
|
protected $table = 'cars';
|
|
|
|
|
|
|
|
protected $allowedFields = ['id', 'name', 'img', 'category', 'width', 'length', 'mass', 'fueltank', 'engine', 'drivetrain'];
|
|
|
|
|
|
|
|
/*
|
|
|
|
public function __construct($car=null)
|
2022-03-14 19:13:10 +01:00
|
|
|
{
|
2024-04-07 22:27:36 +02:00
|
|
|
if ($car) $this->data = $this->data($car);
|
2022-03-14 19:13:10 +01:00
|
|
|
}
|
|
|
|
|
2024-04-07 22:27:36 +02:00
|
|
|
public function getLink(string $text=null): string
|
2022-03-14 19:13:10 +01:00
|
|
|
{
|
2024-04-07 22:27:36 +02:00
|
|
|
if(!$text) $text = $this->data->name;
|
|
|
|
return "<a href='". base_url() . "'/car/{$this->data->id}'>$text</a>";
|
2022-03-14 19:13:10 +01:00
|
|
|
}
|
|
|
|
|
2024-04-07 22:27:36 +02:00
|
|
|
public function card() {
|
|
|
|
return $this->data->name . $this->data->img;
|
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}'>";
|
|
|
|
}
|
|
|
|
|
|
|
|
public function imgTagFull()
|
|
|
|
{
|
|
|
|
return "<img src='" . base_url() . "/{$this->img}' class='car-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() . "/car/{$this->id}'>$content</a>";
|
|
|
|
}
|
|
|
|
|
|
|
|
public function linkTitleImgTag()
|
|
|
|
{
|
|
|
|
$content = $this->name . '<br />' . $this->imgTag();
|
|
|
|
return "<a href='" . base_url() . "/car/{$this->id}'>$content</a>";
|
|
|
|
}
|
2024-04-07 22:27:36 +02:00
|
|
|
*/
|
2022-03-14 19:13:10 +01:00
|
|
|
}
|