DEV Community

Mahmoud Ramadan
Mahmoud Ramadan

Posted on • Edited on

Unlock the Power of the New Easy Model – Available Today! 🎉

I'm thrilled to announce the release of Easy Model v1.1.1, bringing key improvements and new features:

  • Updatable Trait: Perform batch updates efficiently with streamlined methods.
/**
 * Store a newly created resource in storage.
 */
public function store()
{
    return $this
        ->updateOrCreateModel(['name' => 'Mahmoud Ramadan', 'email' => 'easymodel@updatable.org'], [
            'password' => bcrypt('admin'),
        ])
        ->incrementEach(['points' => 2])
        ->fetch();
}
Enter fullscreen mode Exit fullscreen mode
  • ignoreGlobalScopes Method: Exclude specific global scopes to customize your queries with more control.
/**
 * Display a listing of the resource.
 */
public function index()
{
    return $this
        ->setChainableModel(User::class)
        ->addWheres([
            ['name', 'Mahmoud Ramadan']
        ])
        ->usingScopes([
            UserIsAdminScope::class,
            EmailVerifiedScope::class,
        ])
        ->ignoreGlobalScopes([UserIsAdminScope::class])
        ->execute()
        ->get();
}
Enter fullscreen mode Exit fullscreen mode
  • includeSoftDeleted Method: Retrieve soft-deleted records in your results, offering a more comprehensive data set.
/**
 * Display a listing of the resource.
 */
public function index()
{
    return $this
        ->setChainableModel(User::class)
        ->addWheres([
            ['name', 'Mahmoud Ramadan']
        ])
        ->includeSoftDeleted()
        ->execute()
        ->get();
}
Enter fullscreen mode Exit fullscreen mode
  • Renamed setModel Method: The setModel method is now setSearchableModel for clarity and better function.

  • Code Refactor: Improved structure for easier maintenance.

  • Enhanced Readability: Code updates to improve readability and speed up development.

Full Changelog: v1.1.0...v1.1.1

Top comments (0)