/** * Bootstrap any application services. * * @return void */ public function boot() { view()->composer('admin.sidebar', function ($view) { $view->with('adminMenu', [['title' => trans('p.home'), 'route' => 'admin.dashboard', 'icon' => 'home'], ['title' => trans('p.news'), 'route' => '#', 'icon' => 'newspaper-o', 'children' => [['title' => trans('p.add'), 'route' => 'admin.news.create', 'icon' => 'plus-square'], ['title' => trans('p.list'), 'route' => 'admin.news.index', 'icon' => 'list']]], ['title' => trans('p.users'), 'route' => '#', 'icon' => 'users', 'children' => [['title' => trans('p.add'), 'route' => 'admin.user.create', 'icon' => 'user-plus'], ['title' => trans('p.list'), 'route' => 'admin.user.index', 'icon' => 'list']]], ['title' => trans('p.pages'), 'route' => '#', 'icon' => 'file-text-o', 'children' => [['title' => trans('p.add'), 'route' => 'admin.page.create', 'icon' => 'plus-square'], ['title' => trans('p.list'), 'route' => 'admin.page.index', 'icon' => 'list']]], ['title' => trans('p.videocourses'), 'route' => '#', 'icon' => 'play-circle', 'children' => [['title' => trans('p.add'), 'route' => 'admin.videocourse.create', 'icon' => 'plus-square'], ['title' => trans('p.list'), 'route' => 'admin.videocourse.index', 'icon' => 'list']]], ['title' => trans('p.examresults'), 'route' => 'admin.examresult.index', 'icon' => 'check-square-o'], ['title' => trans('p.import'), 'route' => '#', 'icon' => 'database', 'children' => [['title' => trans('p.add'), 'route' => 'admin.import.index', 'icon' => 'plus-square'], ['title' => trans('p.import_examresults_br'), 'route' => 'admin.import.examresult', 'icon' => 'check-square-o'], ['title' => trans('p.import_users_br'), 'route' => 'admin.import.user', 'icon' => 'user-plus']]], ['title' => trans('p.settings'), 'route' => 'admin.settings.index', 'icon' => 'gear']]); }); view()->composer('front.partials.menu', function ($view) { $items = [['title' => trans('p.home'), 'route' => 'index'], ['title' => trans('p.news'), 'route' => 'news.index'], ['title' => trans('p.videocourses'), 'route' => 'videocourse.index']]; if (Auth::check()) { $items[] = ['title' => trans('p.staff'), 'route' => 'staff.index']; $items[] = ['title' => trans('p.students'), 'route' => 'student.index']; $user = Auth::user(); if ('student' == $user->type && $user->result()->first()) { $items[] = ['title' => trans('p.examresults'), 'route' => 'examresult.show', 'param' => $user->email]; } } $view->with('menu', $items); }); view()->composer('front.news.block-random', function ($view) { $news = News::where('status', 'active')->orderByRaw('RAND()')->limit(4)->get(); $random = $news->shift(); $view->with('randomNewsEntry', $random)->with('randomNews', $news); }); view()->composer('front.index', function ($view) { $view->with('latestNews', News::where('status', 'active')->latest()->limit(2)->get()); $view->with('latestVideocourses', VideoCourse::where('status', 'active')->latest()->limit(3)->get()); }); view()->composer('front.partials.footer', function ($view) { $view->with('aboutPage', Page::where('slug', 'about')->first()); }); }
public function deleteFile($id, $all = false) { $path = Input::get('path'); $videcourse = VideoCourse::findOrFail($id); $files = unserialize($videcourse['files']); if ($all && $files) { foreach ($files as $file) { File::delete(public_path() . '/uploads/' . $file); } $videcourse->files = ''; return json_encode(true); } elseif (isset($path) && $path) { File::delete(public_path() . '/uploads/' . $path); if (($key = array_search($path, $files)) !== false) { unset($files[$key]); } $videcourse->files = serialize($files); $videcourse->save(); return json_encode(true); } return json_encode(false); }
/** * Display the specified resource. * * @param string $slug * @return \Illuminate\Http\Response */ public function show($slug) { $videocourse = VideoCourse::where('status', 'active')->where('slug', $slug)->first(); return view('front.videocourses.view', compact('videocourse')); }