Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Sunshine And March Vibes (2025 Wallpapers Edition)

      May 16, 2025

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      May 16, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      May 16, 2025

      How To Prevent WordPress SQL Injection Attacks

      May 16, 2025

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025

      Bing Search APIs to be “decommissioned completely” as Microsoft urges developers to use its Azure agentic AI alternative

      May 16, 2025

      Microsoft might kill the Surface Laptop Studio as production is quietly halted

      May 16, 2025

      Minecraft licensing robbed us of this controversial NFL schedule release video

      May 16, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      The power of generators

      May 16, 2025
      Recent

      The power of generators

      May 16, 2025

      Simplify Factory Associations with Laravel’s UseFactory Attribute

      May 16, 2025

      This Week in Laravel: React Native, PhpStorm Junie, and more

      May 16, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025
      Recent

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025

      Bing Search APIs to be “decommissioned completely” as Microsoft urges developers to use its Azure agentic AI alternative

      May 16, 2025

      Microsoft might kill the Surface Laptop Studio as production is quietly halted

      May 16, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»View Third-party Relations in model:show – Now Available in Laravel 11.11

    View Third-party Relations in model:show – Now Available in Laravel 11.11

    June 19, 2024

    This week, the Laravel team released v11.11, with support for third-party relations in the model:show command, new Collection methods, new cache events, and more.

    before and after Collection Methods

    Ryuta Hamasaki contributed before and after methods to Collection and LazyCollection instances

    Here are examples of the before method from the pull request description:

    $collection = collect([1, 2, 3, 4, 5, ‘name’ => ‘taylor’, ‘framework’ => ‘laravel’]);

    $collection->before(2) // 1
    $collection->before(‘taylor’) // 5
    $collection->before(‘laravel’) // ‘taylor’
    $collection->before(fn ($value) => $value > 4) // 4
    $collection->before(fn ($value) => ! is_numeric($value)) // 5
    $collection->before(1) // null
    $collection->before(‘not found’) // null

    Here are examples of the after method from the pull request description:

    $collection = collect([1, 2, 3, 4, 5, ‘name’ => ‘taylor’, ‘framework’ => ‘laravel’]);

    $collection->after(1) // 2
    $collection->after(‘taylor’) // ‘laravel’
    $collection->after(fn ($value) => $value > 4) // ‘taylor’
    $collection->after(fn ($value) => ! is_numeric($value)) // ‘laravel’
    $collection->after(‘laravel’) // null
    $collection->after(‘not found’) // null

    Cache Events

    Alex Bouma contributed new cache events to the framework that applications can listen to:

    use IlluminateCacheEventsForgettingKey;

    use IlluminateCacheEventsKeyForgetFailed;

    use IlluminateCacheEventsKeyWriteFailed;
    // Two public properties: `$this->value` and `$this->seconds`

    use IlluminateCacheEventsRetrievingKey;

    use IlluminateCacheEventsRetrievingManyKeys;
    // One public property: `$this->keys`

    use IlluminateCacheEventsWritingKey
    // Two public properties: `$this->value` and `$this->seconds`

    use IlluminateCacheEventsWritingManyKeys;
    // Three public properties:
    // `$this->keys`, `$this->values` and `$this->seconds`

    Support Third-party Relations in model:show

    Jonas Staudenmeir contributed the ability to include third-party package model relations in the model:show command:

    The model:show command finds a model’s relations by analyzing the code of its methods and looking for $this->hasMany( etc. This doesn’t detect third-party relations (like eloquent-has-many-deep). We could build a whole system for packages to hook into, but that would be overkill, IMO.

    Instead, we can check the method’s return type and see if it’s a subclass of the base Relation class. Not everybody uses return types, but I hope that most do nowadays.

    You can learn more about this addition in Pull Request #51807.

    Session ID Getter

    Tim MacDonald contributed the Session::id() method to the Session facade:

    Session::id();

    // You can still use `getId()` too:
    Session::getId();

    Timezone and Locale Added to the about Command

    Amir Khalife Soltani contributed to adding Locale and Timezone values to Laravel’s about command. You can now quickly determine what the configured locale and timezone are at a glance with other important environment information:

    The `about` command with `Timezone` and `Locale` values

    422 Unprocessable Content Status Code

    Dwight Watson contributed updates to the status code method for determining a 422 status code, which is now referred to as 422 Unprocessable Content instead of Unprocessable Entity. The way you interact with asserting a 422 status code hasn’t changed:

    $response = $this->postJson(‘/example’, []);
    $response->assertUnprocessable();

    See RFC 9110: HTTP Semantics and Pull Request #51815 for details.

    Add Relation::getMorphAlias() Method

    Dennis Koch contributed a Relation::getMorphAlias() method

    Since there is a Relation::getMorphedModel() I think it would be beneficial to add the reverse getMorphAlias.

    This addition is particularly beneficial for testing, as it simplifies assertions with $this->assertDatabaseHas. Developers no longer need to recall the morph alias used:

    $this->assertDatabaseHas(‘taskables’, [
    ‘taskable_type’ => Relation::getMorphAlias(Document::class),
    ‘taskable_id’ => $mitigation->id,
    ‘task_id’ => $taskB->id
    ]);

    Release notes

    You can see the complete list of new features and updates below and the diff between 11.10.0 and 11.11.0 on GitHub. The following release notes are directly from the changelog:

    v11.11.0

    [11.x] Add get, write and forget cache events by @stayallive in https://github.com/laravel/framework/pull/51560

    [11.x] Add test for Arr::sortRecursiveDesc() method. by @lmottasin in https://github.com/laravel/framework/pull/51716

    [11.x] Fix missing table name in db:table command by @benholmen in https://github.com/laravel/framework/pull/51710

    Ensure files exist for install:broadcasting by @jasonmccreary in https://github.com/laravel/framework/pull/51719

    [11.x] Restore exceptions/errors to test assertion failure messages by @jessarcher in https://github.com/laravel/framework/pull/51725

    [11.x] Test Improvements by @crynobone in https://github.com/laravel/framework/pull/51723

    [11.x] Add tests for accessible and take method by @saMahmoudzadeh in https://github.com/laravel/framework/pull/51724

    Increment the totalJobs property for the BatchFake when add some jobs by @yankewei in https://github.com/laravel/framework/pull/51742

    [11.x] Give session ID retrieval the Laravel treatment by @timacdonald in https://github.com/laravel/framework/pull/51732

    [11.x] Fix the chunk method to an integer type in the splitIn method by @rookiexxk in https://github.com/laravel/framework/pull/51733

    Update:update name method and doc by @mehdi-fathi in https://github.com/laravel/framework/pull/51744

    [11.x] Fixes config:publish with dontMergeFrameworkConfiguration() set to true by @crynobone in https://github.com/laravel/framework/pull/51751

    Updated phpdoc for Builder::from() by @boris-glumpler in https://github.com/laravel/framework/pull/51767

    [11.x] Fixed pop on default Beankstalkd queue when not specifically added by @rinocs in https://github.com/laravel/framework/pull/51759

    [11.x] Add before and after methods to Collection by @avosalmon in https://github.com/laravel/framework/pull/51752

    [11.x] Change scope for afterCreating and afterMaking callbacks by @jacob418 in https://github.com/laravel/framework/pull/51772

    Use numeric literal separator in file rule validation by @AmirKhalifehSoltani in https://github.com/laravel/framework/pull/51781

    [11.x] Import Model class for RendererException by @seriquynh in https://github.com/laravel/framework/pull/51778

    [11.x] About command improvement by @AmirKhalifehSoltani in https://github.com/laravel/framework/pull/51791

    [11.x] Test abort behavior by @seriquynh in https://github.com/laravel/framework/pull/51800

    [11.x] Container shares fixed values/initialized instances instead of singleton closure resolutions by @seriquynh in https://github.com/laravel/framework/pull/51804

    [11.x] Fix altering a table that has a column with default 0 on SQLite by @hafezdivandari in https://github.com/laravel/framework/pull/51803

    [11.x] Fix typo in VendorPublishCommand by @tamiroh in https://github.com/laravel/framework/pull/51812

    [11.x] Fix some typos in the tests by @tamiroh in https://github.com/laravel/framework/pull/51811

    [11.x] Add unprocessableContent and update unprocessableEntity by @dwightwatson in https://github.com/laravel/framework/pull/51815

    [11.x] Improve Queue::assertNothingPushed() error message by @SjorsO in https://github.com/laravel/framework/pull/51814

    [11.x] Add Relation::getMorphAlias() by @pxlrbt in https://github.com/laravel/framework/pull/51809

    [11.x] Support third-party relations in model:show command by @staudenmeir in https://github.com/laravel/framework/pull/51807

    [11.x] Fix nested rules custom attribute names by @owenandrews in https://github.com/laravel/framework/pull/51805

    [11.x] Fix docblock of IlluminateHttpResponse by @seriquynh in https://github.com/laravel/framework/pull/51823

    The post View Third-party Relations in model:show – Now Available in Laravel 11.11 appeared first on Laravel News.

    Join the Laravel Newsletter to get all the latest Laravel articles like this directly in your inbox.

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous Articlemoonshine/moonshine
    Next Article Desktop application development with Angular and Electron

    Related Posts

    Machine Learning

    LLMs Struggle with Real Conversations: Microsoft and Salesforce Researchers Reveal a 39% Performance Drop in Multi-Turn Underspecified Tasks

    May 17, 2025
    Machine Learning

    This AI paper from DeepSeek-AI Explores How DeepSeek-V3 Delivers High-Performance Language Modeling by Minimizing Hardware Overhead and Maximizing Computational Efficiency

    May 17, 2025
    Leave A Reply Cancel Reply

    Continue Reading

    CVE-2025-3278 – “UrbanGo Membership Plugin Privilege Escalation Vulnerability”

    Common Vulnerabilities and Exposures (CVEs)

    JsonTree v2.3.0 – Beautiful visualised Json Trees! Now with BigInt, Symbol, and custom parsing support!

    Development

    Is it possible to validate response with json schema file in karate?

    Development

    Multi-Year Cyberattack: Chinese Hackers Suspected in Breaching Volkswagen

    Development

    Highlights

    Development

    Random Forest Algorithm in Machine Learning

    January 27, 2025

    Learn how the Random Forest algorithm works in machine learning. Discover its key features, advantages,…

    This small 4K projector is worthy of replacing your TV – and it’s the brightest one I’ve tested

    December 30, 2024

    CISA Launches Ransomware Vulnerability Warning Pilot to Protect Critical Infrastructure

    April 26, 2024

    highlight.js – syntax highlighter

    February 7, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.