How can use variable value in blade file without compact from controller

Published

I found a project file . this has homecontroller as follow

 public function index()
    {
        return view('home');
    }

it redirect to home view.
I check home view


 <div class="m-heading-1 border-dark m-bordered">
                        <p>{!! $charge->update_text !!} </p>
                        <p> For more info please check out
                            <a class="btn purple btn-outline"  href="#upgradeModal" data-toggle="modal">Upgrade Now</a>
                        </p>
                    </div>

it use $charge variable without passing from compact.
I check AppServiceProvider

public function boot()
    {
        Schema::defaultStringLength(191);
       
        $charge = ChargeCommision::find(1);
       
        View::share(compact( 'charge'));
    }

It register $charge in AppServiceProvider.
It already had ChargeComission model and data table .
Can use variable as this without using comapct from controller in laravel?

Source: Laravel

Published
Categorised as laravel Tagged

Answers

Leave a Reply

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq