Premium Component
This is a premium Content. Upgrade to access the content and more premium features.
Upgrade to PremiumDeveloperBreeze
It looks like you're using an adblocker. Our website relies on ads to keep running. Please consider disabling your adblocker to support us and access the content.
This is a premium Content. Upgrade to access the content and more premium features.
Upgrade to PremiumMore content you might like
Use the withDefault() method to set a default related model when none exists:
public function author()
{
return $this->belongsTo(User::class)->withDefault([
'name' => 'Guest Author',
]);
} Cache::remember('shared_data', 3600, function () {
return [
'max_uploads' => 10,
'api_rate_limit' => 100,
'features' => [
'uploads_enabled' => true,
'comments_enabled' => false,
],
];
});Add the newly created provider to the providers array in config/app.php:
'providers' => [
// Other service providers
App\Providers\CustomDataServiceProvider::class,
], php artisan make:provider SharedDataServiceProviderOpen the generated file in app/Providers/SharedDataServiceProvider.php and define a singleton for the shared data:
Please sign in to join the discussion.
No comments yet. Be the first to share your thoughts!