Category: Laravel

Laravel 5.7 Improved Error Messages for Dynamic Calls

Laravel 5.7 makes it easier than ever to track down error messages caused by dynamic calls to Eloquent models (and other parts of the framework) thanks to Bouncer developer Joseph Silber! You’ll get a more clear picture of the error caused by a missing method instead of a possibly confusing error on the underlying object: Ever mistyped a method on an Eloquent model and got a cryptic error saying that the method doesn't exist *on the query builder* ???? Well, in @laravelphp 5.7 you'll now get a clear, concise message saying that the method doesn't exist on the model...

Read More

Laravel Love: Likes and Dislikes for Eloquent Models

Laravel Love is a package by Anton Komarev that lets people express how they feel about content by liking and disliking Eloquent models. The package works by defining a “liker” model defined with a contract. Most likely this will be your application’s User model: <?php use CogContractsLoveLikerModelsLiker as LikerContract; use CogLaravelLoveLikerModelsTraitsLiker; use IlluminateFoundationAuthUser as Authenticatable; class User extends Authenticatable implements LikerContract { use Liker; } On the other end, you define Eloquent models that can be “liked” by your “liker” model: use CogContractsLoveLikeableModelsLikeable as LikeableContract; use CogLaravelLoveLikeableModelsTraitsLikeable; use IlluminateDatabaseEloquentModel; class Article extends Model implements LikeableContract { use Likeable; }...

Read More

Laravel 5.7 Callable Action URLs

A new callable-like syntax for action URLs is coming to Laravel 5.7 thanks to Sebastian De Deyne! You might also hear this feature called “tuple notation” or a “callable array syntax” for URL generation actions. Here’s how it works starting in 5.7: <?php $url = action([PostsController::class, 'index']); Currently (as of Laravel 5.6) the action helper only supports the following style that you’re probably already familiar with: <?php $url = action('UserController@profile', ['id' => 1]); One benefit of the new callable array syntax format is the ability to navigate to directly to the controller if you use a text editor or...

Read More

Laravel Befriended

Right on the heels of our post about Laravel Love: Likes and Dislikes for Eloquent Models, a reader mentioned another similar package called Befriended: Eloquent Befriended brings social media-like features like following, blocking and filtering content based on following or blocked models. Laravel Befriended comes with scopes that manage filtering content that gives you easy control better what your user can see and cannot see. Befriended uses traits and contracts to implement the ability to follow, block, and like Eloquent models. Although the readme examples show the User model, it can be for any eloquent model. For example, you...

Read More

Security Release: Laravel v5.6.30 and v5.5.42 have been released

Laravel 5.6.30 and Laravel 5.5.42 have both been released to fix a security issue and is recommended that all users upgrade as soon as possible. According to the upgrade docs: This vulnerability may only be exploited if your application encryption key (APP_KEY environment variable) has been accessed by a malicious user. Typically, it is not possible for users of your application to gain access to this value. However, ex-employees that had access to the encryption key may be able to use the key to attack your applications. If you have any reason to believe your encryption key is in...

Read More