芝麻web文件管理V1.00
编辑当前文件:/home/royashxg/bit-alphas-ltd.com/user/project/app/Http/Controllers/Admin/SitemapController.php
middleware('auth:admin'); } //*** JSON Request public function datatables() { $datas = Sitemap::orderBy('id','desc'); //--- Integrating This Collection Into Datatables return Datatables::of($datas) ->addColumn('action', function(Sitemap $data) { $delete = '
'; $download = '
Download
'; return '
'.$delete.$download.'
'; }) ->rawColumns(['action']) ->toJson(); //--- Returning Json Data To Client Side } //*** GET Request public function index() { return view('admin.sitemap.index'); } //*** GET Request public function create() { return view('admin.sitemap.create'); } public function store(Request $request){ //--- Validation Section $rules = [ 'sitemap_url' => 'required', ]; $validator = Validator::make($request->all(), $rules); if ($validator->fails()) { return response()->json(array('errors' => $validator->getMessageBag()->toArray())); } //--- Validation Section Ends $data = new Sitemap(); $input = $request->all(); $filename = 'sitemap'.uniqid().'.xml'; SitemapGenerator::create($request->sitemap_url)->writeToFile('assets/sitemaps/'.$filename); $input['filename'] = $filename; $input['sitemap_url'] = $request->sitemap_url; $data->fill($input)->save(); //--- Redirect Section $msg = 'Data Added Successfully.'; return response()->json($msg); //--- Redirect Section Ends } public function delete($id){ $data = Sitemap::find($id); @unlink('assets/sitemaps/'.$data->filename); $data->delete(); $msg = 'Data Deleted SuccessFully'; return response()->json($msg); } }