nativegallery/app/Models/Photo.php
2025-02-25 23:02:05 +03:00

55 lines
No EOL
1.6 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace App\Models;
use \App\Services\DB;
class Photo {
public $photoid;
private $photo;
function __construct($photo_id) {
$this->photoid = $photo_id;
$this->photo = DB::query("SELECT * FROM photos WHERE id=:id", array(':id'=>$this->photoid))[0];
}
public function i($table) {
return $this->photo[$table];
}
public function exists(): bool
{
return $this->i('id') !== null;
}
public static function fetchAll($user_id = NULL) {
if ($user_id != NULL) {
return DB::query("SELECT COUNT(*) FROM photos WHERE user_id=:id", array(':id'=>$user_id))[0]['COUNT(*)'];
}
}
public function content($table) {
$content = json_decode(self::i('content'), true);
return $content[$table];
}
public function declineReason($number) {
switch ($number) {
case 1:
return 'Малоинформативный бред';
break;
case 2:
return 'Не подходит для сайта';
break;
case 3:
return 'Порнография';
break;
case 4:
return 'Травля/Издевательство над человеком';
break;
case 5:
return 'Расчленёнка';
break;
case 6:
return 'Файл сломан';
break;
default:
return 'Не подходит для сайта';
break;
}
}
}