How to insert favicon in laravel?

Viewed 254

I want to insert favicon in design dynamically for this purpose i have created page and made it connected to database in this page i can upload image for favicon and it will be inserted into database but when i want to call back this favicon picture for other page title nothing will be changed

Following Code is in App Service Provider page:

$settings = Setting::all();  
foreach ($settings as $key => $setting) { 

       elseif($key === 0) $favicon = $setting->value;

       elseif($key === 1) $admin_logo = $setting->value;  
   }





   $shareData = array( 

    'favicon'=>$favicon,

    'admin_logo'=>$admin_logo

   );

And it is in other page that i want to call back to it :

<link rel="shortcut icon" href="{{ asset('others') }}/{{ $shareData['favicon'] }}">
2 Answers

Here is my sample code, in AppServiceProvider.php in boot() method, follow below sample code

public function boot()
{
    \View::composer('*', function ($view) {

     $settings = Setting::all();  
       foreach ($settings as $key => $setting) { 

        if($key === 0) $favicon = $setting->value;
        if($key === 1) $admin_logo = $setting->value;  
      }

     $shareData = array( 
      'favicon'=>$favicon,
      'admin_logo'=>$admin_logo
     );

            $view->with('shareData',$shareData);
     }
    });
}

my code was correct but it was chrome browser problem to load that favicon

Related