mirror of
https://github.com/claradex/nativegallery.git
synced 2024-11-16 03:59:09 +03:00
25 lines
750 B
PHP
25 lines
750 B
PHP
<?php
|
|
|
|
namespace App\Controllers\Api\Images;
|
|
|
|
|
|
|
|
use App\Services\{Auth, Router, GenerateRandomStr, DB, Json, EXIF};
|
|
use App\Models\{User, Vote};
|
|
|
|
|
|
class Favorite
|
|
{
|
|
public function __construct()
|
|
{
|
|
$postId = explode('/', $_SERVER['REQUEST_URI'])[3];
|
|
if (DB::query('SELECT * FROM photos_favorite WHERE photo_id = :id AND user_id=:uid', ['id' => $postId, ':uid'=>Auth::userid()])) {
|
|
DB::query('DELETE FROM photos_favorite WHERE photo_id = :id AND user_id=:uid', ['id' => $postId, ':uid'=>Auth::userid()]);
|
|
echo 0;
|
|
} else {
|
|
DB::query('INSERT INTO photos_favorite (photo_id, user_id) VALUES (:id, :uid)', ['id' => $postId, ':uid'=>Auth::userid()]);
|
|
echo 1;
|
|
}
|
|
|
|
}
|
|
}
|