芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/portpulselogistics.com/Modules/Blog/Widgets/RecentComments.php
name = [ 'en' => 'Recent Comments', 'ar' => 'Recent Comments' ]; // you must be define name before run parent construct parent::__construct(); } /** * View form in admin page. * * @param array $oldData * @return View */ public function form($oldData = [], $id = null) { $adminTheme = env('ADMIN_THEME', 'adminLte');return view('blog::'.$adminTheme.'.widgets.recentcomments.form')->with(['oldData' => $oldData]); } /** * View in frontend page (in sidebar). * * @return View */ public function view($id, $data) { $parent_only = isset($data['parent_only']) && $data['parent_only'] == 1; $query_comments = Comment::status()->latest()->limit($data['comments_count'])->with(['creator', 'commentable']); if ($parent_only) { $query_comments->level(1); } $comments = $query_comments->get(); $adminTheme = env('ADMIN_THEME', 'adminLte');return view('blog::'.$adminTheme.'.widgets.recentcomments.view')->with(['data' => $data, 'comments' => $comments]); } /** * Maping data * map data for passing to validation and store or update method * @param array $request * @return array */ public function mapData($request, $id = null) { $request['parent_only'] = isset($request['parent_only']) ? 1 : 0; return $request; } /** * Handle creating data * * Run this method when clicked on save when create new widget * here handle and map your data to save in database * examples: * upload image. * * @param collection $widget -> old object data from database * @param array $request -> form data * @return array */ public function store($request) { return $request; } /** * Handle update data * * Run this method when clicked on save * here handle and map your data to save in database * examples: * upload image. * @param collection $widget -> old object data from database * @param array $request -> form data * @return array */ public function update($widget, $request) { return $request; } /** * Validation data (Run automatically) * * Remove it if you need not apply validations * Use it when you need make validation in your data form * @param array $data * @return array|boolean */ public function validation($data, $id = null) { $validation = Validator::make($data, [ 'comments_count' => 'required|integer|max:20', ]); // validate data if ($validation->fails()) { return $validation->errors(); } else { return true; } } }