HEX
Server: nginx/1.18.0
System: Linux test-ipsremont 5.4.0-214-generic #234-Ubuntu SMP Fri Mar 14 23:50:27 UTC 2025 x86_64
User: ips (1000)
PHP: 8.0.30
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/ipsremont-demo/app/Models/OrderItems.php
<?php


namespace App\Models;


use App\Traits\Displayed;
use App\Traits\My;
use App\Traits\Sortable;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\DB;

/**
 * @property int $order_id
 * @property int $part_id
 * @property int $amount
 * @property ?string $deleted_at
 * @property ?string $created_at
 * @property ?string $updated_at
 * @property float $price
 * @property ?string $part_external_id
 *
 * @property Part $part
 */
class OrderItems extends BaseModel
{

    use SoftDeletes, Sortable, Displayed, My;

    protected $table = 'order_items';

    protected $fillable = [
        'order_id',
        'part_id',
        'amount',
        'price',
        'deleted_at',
        'part_external_id',
    ];

    public function _save($order_id, $part_id, $amount, $price, $part_external_id)
    {
        $this->order_id = $order_id;
        $this->part_id = $part_id;
        $this->amount = $amount;
        $this->price = $price;
        $this->part_external_id = $part_external_id;
        $this->save();
    }

    public function _update($order_id, $part_id, $amount, $price, $part_external_id)
    {
        DB::statement("UPDATE `order_items` SET `amount`=$amount,`price`=$price,`part_external_id`=\"$part_external_id\", `deleted_at` = NULL WHERE `order_id`=$order_id AND `part_id`=$part_id");
    }

    // MARK: - Relations

    public function part(): BelongsTo
    {
        return $this->belongsTo(Part::class)->withTrashed();
    }

}