/**
  * Update the specified card in storage.
  *
  * @param  Card  $card
  * @return Response
  */
 public function update(Card $card, CardRequest $request)
 {
     $card->id = $request->get('id');
     $card->user()->associate($request->get('user_id'));
     $card->save();
     return redirect()->route('admin.cards.index');
 }
예제 #2
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $name = $request->get('name');
     if (!empty($name)) {
         $card = new Card();
         $card->name = $name;
         $card->save();
         return redirect()->route('admin.cards.index')->with('message', 'Thêm mới thành công');
     }
     return redirect()->route('admin.cards.index')->with('message', 'Thêm mới không thành công');
 }
예제 #3
0
 /**
  * 新建卡片保存处理
  * @param Request $request
  * @return mixed
  */
 public function store(Request $request)
 {
     // 数据检证
     // $this->validate($request, [
     // 	'title' => 'required|unique:pages|max:255',
     // 	'body' => 'required',
     // ]);
     $objCard = new Card();
     // Card Model 内容
     $objCard->name_cn = Input::get('name_cn');
     $objCard->name_jp = Input::get('name_cn');
     $objCard->name_en = Input::get('name_cn');
     //        $objCard->name_jp = Input::get('name_jp');
     //        $objCard->name_en = Input::get('name_en');
     $objCard->desc_cn = Input::get('desc_cn');
     $objCard->desc_jp = Input::get('desc_cn');
     $objCard->desc_en = Input::get('desc_cn');
     //        $objCard->desc_jp = Input::get('desc_jp');
     //        $objCard->desc_en = Input::get('desc_en');
     //        $objCard->icon = Input::get('icon');
     //        $objCard->image = Input::get('image');
     $objCard->race = Input::get('race');
     $objCard->rare = Input::get('rare');
     $objCard->attr = Input::get('attr');
     $objCard->cost = Input::get('cost');
     $objCard->job = Input::get('job');
     $objCard->max_level = Input::get('max_level');
     $objCard->skill_id = Input::get('skill_id', 0);
     // $card->lskill_id = Input::get('lskill_id');
     // $card->skill_id  = 1; // TEST
     $objCard->lskill_id = 1;
     // TEST
     $objCard->init_hp_min = Input::get('init_hp_min');
     $objCard->init_atk_min = Input::get('init_atk_min');
     $objCard->init_def_min = Input::get('init_def_min');
     $objCard->init_spd_min = Input::get('init_spd_min');
     $objCard->init_int_min = Input::get('init_int_min');
     $objCard->grow_hp_min = (double) Input::get('grow_hp_min');
     $objCard->grow_atk_min = (double) Input::get('grow_atk_min');
     $objCard->grow_def_min = (double) Input::get('grow_def_min');
     $objCard->grow_spd_min = (double) Input::get('grow_spd_min');
     $objCard->grow_int_min = (double) Input::get('grow_int_min');
     $objCard->init_hp_max = Input::get('init_hp_max');
     $objCard->init_atk_max = Input::get('init_atk_max');
     $objCard->init_def_max = Input::get('init_def_max');
     $objCard->init_spd_max = Input::get('init_spd_max');
     $objCard->init_int_max = Input::get('init_int_max');
     $objCard->grow_hp_max = (double) Input::get('grow_hp_max');
     $objCard->grow_atk_max = (double) Input::get('grow_atk_max');
     $objCard->grow_def_max = (double) Input::get('grow_def_max');
     $objCard->grow_spd_max = (double) Input::get('grow_spd_max');
     $objCard->grow_int_max = (double) Input::get('grow_int_max');
     $objCard->ability_id_1 = 1;
     //TEST
     $objCard->ability_id_2 = 2;
     //TEST
     $objCard->ability_id_3 = 3;
     //TEST
     // $card->ability_id_1 = input::get('ability_id_1');
     // $card->ability_id_2 = Input::get('ability_id_2');
     // $card->ability_id_3 = Input::get('ability_id_3');
     $objCard->admin_memo = Input::get('admin_memo');
     // 原则上做成时非公开
     $objCard->open = false;
     // $card->update_datetime = now();
     if ($objCard->save()) {
         return Redirect::to('admin/card');
     } else {
         return Redirect::back()->withInput()->withErrors('保存失败!');
     }
 }
예제 #4
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $card = new Card();
     /* 基本信息 */
     $card->card_id = Input::get('card_id');
     $card->name_jp = Input::get('name_jp');
     /* 基本数据 */
     $card->cost = Input::get('cost');
     $card->max_level = Input::get('max_level');
     $card->rare = Input::get('rare');
     $card->attr1 = Input::get('attr1');
     $card->type1 = Input::get('type1');
     //主Type
     $card->type2 = Input::get('type2');
     //副Type
     /* 能力1 */
     $card->ability1 = Input::get('ability1');
     $card->ability2 = Input::get('ability2');
     $card->ability3 = Input::get('ability3');
     // 属性2 未实装
     // if (Input::get('attr2')) {
     // 	$card->attr2 = Input::get('attr2');
     // } else {
     // 	$card->attr2 = 0;
     // }
     /* 基础数值 */
     $card->init_hp = Input::get('init_hp');
     $card->max_hp = Input::get('max_hp');
     $card->init_atk = Input::get('init_atk');
     $card->max_atk = Input::get('max_atk');
     $card->min_atk_count = Input::get('min_atk_count');
     $card->max_atk_count = Input::get('max_atk_count');
     /* 技能 */
     $card->skill_id = Input::get('skill_id');
     $card->lskill_id = Input::get('lskill_id');
     /* 进化相关 */
     $card->material_id1 = Input::get('material_id1');
     $card->material_id2 = Input::get('material_id2');
     $card->material_id3 = Input::get('material_id3');
     $card->material_id4 = Input::get('material_id4');
     $card->evo_id = Input::get('evo_id');
     /* 其他 */
     // $card->exp       = Input::get('exp');
     $card->soul_num = Input::get('soul_num');
     if (Input::get('key') && Input::get('key') != '') {
         $card->key = Input::get('key');
         // 俗称
     }
     if (Input::get('commit') && Input::get('commit') != '') {
         $card->commit = Input::get('commit');
         // 评价
     }
     if (Input::get('start_star') && Input::get('start_star') != '') {
         $card->start_star = Input::get('start_star');
         //初始评价度
     }
     $statusStar = 0;
     $card->status_star = $statusStar;
     // 数据评价度
     if (Input::get('series') && Input::get('series') != '') {
         $card->series = Input::get('series');
         // 俗称
     }
     /* 箭头 */
     $card->arrow1 = Input::get('arrow1');
     $card->arrow2 = Input::get('arrow2');
     $card->arrow3 = Input::get('arrow3');
     $card->arrow4 = Input::get('arrow4');
     $card->arrow5 = Input::get('arrow5');
     $card->arrow6 = Input::get('arrow6');
     $card->arrow7 = Input::get('arrow7');
     $card->arrow8 = Input::get('arrow8');
     /* 图片剪切 */
     $intIconHeight = 106;
     $intIconWeight = 106;
     $intImageHeight = 563;
     $intImageWeight = 490;
     $intIconStartX = 163;
     $intIconStartY = 826;
     $intImageStartX = 139;
     $intImageStartY = 192;
     $intImageType = Input::get('image_type');
     switch ($intImageType) {
         case 1:
             // iPhone6/6s Plus
             break;
         case 2:
             // iPhone6/6s
             $intIconHeight = 121;
             $intIconWeight = 121;
             $intImageHeight = 557;
             $intImageWeight = 625;
             $intIconStartX = 64;
             $intIconStartY = 928;
             $intImageStartX = 39;
             $intImageStartY = 224;
             break;
         case 3:
             // iPhone5/5s
             $intIconHeight = 102;
             $intIconWeight = 102;
             $intImageHeight = 520;
             $intImageWeight = 466;
             $intIconStartX = 157;
             $intIconStartY = 785;
             $intImageStartX = 137;
             $intImageStartY = 197;
             break;
         case 4:
             // iPhone4/4s
             break;
         case 5:
             // L的魅族
             $intIconHeight = 171;
             $intIconWeight = 171;
             $intImageHeight = 792;
             $intImageWeight = 880;
             $intIconStartX = 97;
             $intIconStartY = 1331;
             $intImageStartX = 63;
             $intImageStartY = 335;
             break;
         default:
             # code...
             break;
     }
     $dataImageFile = Input::file('image_file', NULL);
     if ($dataImageFile && $dataImageFile->isValid()) {
         $clientName = $dataImageFile->getClientOriginalName();
         //客户端文件名称..
         $tmpName = $dataImageFile->getFileName();
         //缓存在tmp文件夹中的文件名例如php8933.tmp 这种类型的.
         $realPath = $dataImageFile->getRealPath();
         ///这个表示的是缓存在tmp文件夹下的文件的绝对路径
         $entension = $dataImageFile->getClientOriginalExtension();
         //上传文件的后缀.
         $mimeTye = $dataImageFile->getMimeType();
         //大家对mimeType应该不陌生了. 我得到的结果是 image/jpeg.
         /* 源图片保存 */
         $strIconPath = $dataImageFile->move(public_path() . '/images/card/resources/' . $card->card_id . '.jpg', $clientName);
         $resourceImage = imagecreatefromjpeg($strIconPath);
         /* ICON */
         $dataIconImageFile = imagecreatetruecolor($intIconWeight, $intIconHeight);
         imagecopyresampled($dataIconImageFile, $resourceImage, 0, 0, $intIconStartX, $intIconStartY, $intIconWeight, $intIconHeight, $intIconWeight, $intIconHeight);
         imagepng($dataIconImageFile, public_path() . '/images/card/icon/' . $card->card_id . '.png', 0);
         $strIconRelativePath = '/images/card/icon/' . $card->card_id . '.png';
         $card->icon = $strIconRelativePath;
         /* IMAGE */
         $dataImageImageFile = imagecreatetruecolor($intImageWeight, $intImageHeight);
         imagecopyresampled($dataImageImageFile, $resourceImage, 0, 0, $intImageStartX, $intImageStartY, $intImageWeight, $intImageHeight, $intImageWeight, $intImageHeight);
         imagepng($dataImageImageFile, public_path() . '/images/card/image/' . $card->card_id . '.png', 0);
         $strImageRelativePath = '/images/card/image/' . $card->card_id . '.png';
         $card->image = $strImageRelativePath;
     }
     if ($card->save()) {
         return Redirect::to('admin/card#create');
     } else {
         return Redirect::back()->withInput()->withErrors('保存失败!');
     }
 }