public function updateVersion(Version $id, Request $request)
 {
     $id->version = $request->version;
     $id->url = $request->url;
     $id->detail = $request->detail;
     $id->force_update = $request->force_update;
     if ($id->save()) {
         $data['status'] = 0;
     } else {
         $data['status'] = 10000;
         $data['msg'] = '更新失败';
     }
     return $data;
 }
示例#2
0
 public function downloadFile()
 {
     $last = Version::orderBy('updated_at', 'desc')->first();
     if (!$last) {
         return view('home.download.error');
     }
     return response()->download($last->app_url);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $version = Version::all()->first();
     $champions = $this->getChampions();
     Model::unguard();
     foreach ($champions['keys'] as $key) {
         $img = "http://ddragon.leagueoflegends.com/cdn/" . $version->release . "/img/champion/" . $champions['data'][$key]['key'] . ".png";
         Champion::create(['riot_id' => $champions['data'][$key]['id'], 'name' => $champions['data'][$key]['name'], 'title' => $champions['data'][$key]['title'], 'key' => $champions['data'][$key]['key'], 'image' => $img, 'lore' => $champions['data'][$key]['lore']]);
     }
 }
示例#4
0
 public function update(array $data, $id)
 {
     $version = Version::find($id);
     $version->title = $data['title'];
     $version->version_code = $data['version_code'];
     $version->version_name = $data['version_name'];
     $version->description = $data['description'];
     $version->app_url = $data['app_url'];
     $version->user_id = Auth::id();
     $version->save();
     return $version;
 }
示例#5
0
 public static function boot()
 {
     // NOTE events cycle is as follows:
     // saving   -> creating -> created   -> saved
     // saving   -> updating -> updated   -> saved
     // deleting -> deleted  -> restoring -> restored
     parent::boot();
     static::saved(function ($page) {
         // Build markup
         $markup = markup($page->source);
         self::where([$page->getKeyName() => $page->getKey()])->limit(1)->update(['markup' => $markup]);
         // Backup version
         return Version::createFromPage($page);
     });
 }
示例#6
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     //
     $version = Version::find($id);
     $version->delete();
     if ($version->id) {
         flash()->success('操作成功');
     } else {
         flash()->error('操作失败');
     }
     return redirect()->back();
 }
示例#7
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     //
     $versions = Version::orderBy('created_at', 'desc')->get();
     return view('admin.version.index', compact('versions'));
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Version::destroy($id);
 }
示例#9
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function getLastVersion()
 {
     //获取最新版本信息
     $version = Version::orderBy('created_at', 'DESC')->first();
     return response()->json($version);
 }