I have a problem when I learning laravel. My views include master.blade.php and top.blade.php file.
In master.blade.php, I used @include('top') command to get content show UI. But now I don't know how to get and passing database to top.blade.php. I was used direct App\Article; to do this. can anyone help me? thanks.
Master.blade.php file
@include('top')
Top.blade.php file
<?php
use App\Article;
$articles = Article::orderBy(DB::raw('RAND()'))->take(1)->get();
?>
@foreach ($articles as $a)
{{ $a->title }}
@endforeach