/**
  * Store a newly created resource in storage.
  * @param ItemFormRequest $request
  * @return mixed
  */
 public function store(ItemFormRequest $request)
 {
     $item = new Item();
     $item->name = $request->get('name');
     $item->active = $request->get('active');
     $item->save();
     return \Redirect::route('item')->with('message', 'Item saved');
 }
示例#2
0
文件: Shop.php 项目: Synthx/Acamar
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (\App\Model\Item::findOrFail($request->route('id'))->shop != 1) {
         return abort(404);
     }
     return $next($request);
 }
示例#3
0
 /**
  * Buy an object on shop
  * POST
  *
  * @param Request $request
  * @param int $id
  * @param string $name
  * @return Response
  */
 public function buyObject(Request $request, $id, $name)
 {
     $this->validate($request, ['player' => 'required|numeric|exists:personnages,guid', 'cgu' => 'required']);
     $item = ItemManager::find($id);
     $user = \App\Model\User::find(Auth::user()->guid);
     if ($item->stock == 0) {
         return redirect()->back();
     } elseif ($item->price > $user->points) {
         return redirect()->back();
     }
     $user->points -= $item->price;
     $user->save();
     $item->stock -= 1;
     $item->save();
     $action = new \App\Model\Action();
     $action->PlayerID = $request->player;
     $action->Action = 21;
     $action->Nombre = $item->id;
     $action->save();
     return redirect()->route('shop.home');
 }
示例#4
0
 /**
  * Play lotery
  * POST
  *
  * @param Request $request
  * @return Response
  */
 public function playLotery(Request $request)
 {
     $this->validate($request, ['player' => 'required|numeric|exists:personnages,guid']);
     $item = ItemManager::where('lotery', 1)->orderByRaw('RAND()')->first();
     $user = UserManager::find(Auth::user()->guid);
     if ($user->points < config('config.points.lotery')) {
         return redirect()->back();
     }
     $user->points -= config('config.points.lotery');
     $user->save();
     $action = new \App\Model\Action();
     $action->PlayerID = $request->player;
     $action->Action = 21;
     $action->Nombre = $item->id;
     $action->save();
     return view('points.success', compact('item'));
 }
示例#5
0
文件: Player.php 项目: synthx/infuse
 /**
  * Get all item's wear by players in array
  *
  * @param string $objectString
  */
 public function getItems($objectString)
 {
     $objectArray = [];
     if (!empty($objectString)) {
         $objectIds = explode('|', $objectString);
         foreach ($objectIds as $objectId) {
             if (!empty($objectId)) {
                 array_push($objectArray, $objectId);
             }
         }
     }
     $items = ItemManager::select('stats', 'panoplie')->join('item_template', 'item_template.id', '=', 'items.template')->whereIn('guid', $objectArray)->where('pos', '!=', '-1')->get();
     return $items;
 }
示例#6
0
 public function getItems()
 {
     if (count($this->items) === 0) {
         $this->items = Item::getItemsForAuction($this->id);
     }
     return $this->items;
 }
示例#7
0
 public function getItems()
 {
     return Item::getItemsForCategory($this->id);
 }