решили проблему. Мне просто нужно передать $ posts через use ($ posts) и добавить -> with (compact ('posts')) в loadView
public function exportDatedPosts(Request $request)
{
$dateStart = $request->startDate;
$dateEnd = $request->endDate;
$posts = DB::table('posts')
->distinct()
->leftJoin('post_tag', 'posts.id', '=', 'post_tag.post_id')
->leftJoin('tags', 'tags.id', '=', 'post_tag.tag_id')
->leftJoin('users', 'users.id', '=', 'posts.user_id')
->select('posts.title', 'posts.body' ,'users.name as user')
->whereBetween('posts.created_at', [$dateStart, $dateEnd])
->get();
Excel::create('PostsReport', function($excel) use($posts)
{
$excel->sheet('New sheet', function($sheet) use($posts)
{
$sheet->loadView('ExImports.DatedPost')->with(compact('posts'));
});
})->export('csv');
}