Answers for "laravel model is dirty"

PHP
1

show user only those product which he hasn't buyed laravel eloquest

$user_id = auth()->user()->id;

Product::where('status', 'active')
  ->whereNotIn('id', function($query) use ($user_id) {
    $query->select('product_id')->from(new OrderProduct->getTable())
      ->where('user_id', $user_id)->where('status', 'delivered')
		->pluck('product_id')->toArray();
  });
Posted by: Guest on June-26-2020
1

laravel model is dirty

if($product->isDirty()){
    // changes have been made
}
Posted by: Guest on December-28-2020
0

laravel update only changed fields

protected function performUpdate(Builder $query, array $options = [])
{
    $dirty = $this->getDirty();

    if (count($dirty) > 0)
    {
        // runs update query
    }

    return true;
}
Posted by: Guest on September-27-2020

Browse Popular Code Answers by Language