restore composer.json, add mysqli extension

This commit is contained in:
2026-04-15 17:02:52 +05:00
commit 77cf56a348
4317 changed files with 1397107 additions and 0 deletions

80
app/Models/Favorite.php Executable file
View File

@@ -0,0 +1,80 @@
<?php
namespace App\Models;
use App\Models\User;
use App\Models\Product;
use Illuminate\Database\Eloquent\Model;
/**
* @package App\Models
* @property int|null $user_id
* @property string|null $token
* @property int $product_id
*
* @property-read User $user
* @property-read Product $product
*/
class Favorite extends Model
{
protected $table = 'products_users';
public $timestamps = false;
public $incrementing = false;
/**
* @var array
*/
protected $fillable = [
'user_id', 'product_id', 'token'
];
/**
* @var array
*/
protected $casts = [
'user_id' => 'integer',
'product_id' => 'integer',
'token' => 'string'
];
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
{
return $this->belongsTo(User::class);
}
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function product()
{
return $this->belongsTo(Product::class);
}
/**
* @param $query
* @param $token
* @return mixed
*/
public function scopeFindByToken($query, $token)
{
return $query->where('token', $token);
}
/**
* @param $query
* @return mixed
*/
public function scopeFindByList($query)
{
if (auth()->check()) {
return $query->where('user_id', auth()->user()->id);
}
return $query->where('token', request()->cookie('token'));
}
}