/** * Run the database seeds. * * @return void */ public function run() { $resources = array_merge($this->resourceRoutes('users')); foreach ($resources as $resource) { Resource::create($resource); } }
/** * Creates enough resources to ensure that all distros are available as resources. */ public function run() { $faker = Faker::create(); foreach (range(1, 50) as $index) { $os = $faker->randomElement(array_keys($this->distros)); Resource::create(['os' => $os, 'os_version' => $faker->randomElement($this->distros[$os]), 'local_ip' => $faker->localIpv4()]); } }
/** * creates a city and the belonging models (BuildingSlot, Resource, HumanResource) * saves the city in the map * * @param User $user The user to whom the city belongs * @param bool $capital Is the city a capital * @param int $hex_id the id of the hex on which the city is located * @param string $name the name of the city */ public static function create(array $attributes) { /** @var City $city */ $city = parent::create($attributes); /** @var BuildingSlot $slot */ $slot = BuildingSlot::create(['city_id' => $city->id]); Resource::create(['city_id' => $city->id]); HumanResource::create(['city_id' => $city->id]); $city->building_slot = $slot->id; $city->save(); /** @var Building $wall */ $wall = Building::create(['city_id' => $city->id, 'slot' => $slot->id, 'nation' => $attributes['nation'], 'type' => 9, 'finished_at' => Carbon::now()]); $slot->wall = $wall->id; $slot->save(); /** @var Grid $hex */ $hex = Grid::find($hex_id); $hex->update(['owner_id' => $attributes['owner'], 'city_id' => $city->id]); $hex->setNeighborsOwner($attributes['owner']); }
public function store(Request $request) { if (!Auth::check()) { return response()->json($this->notLoginJson, 401); } else { $user = Auth::user(); if (!$user->hasRole('admin')) { return response()->json($this->needPermissionsJson, 401); } } $data = $request->only('type', 'available', 'using', 'damaged'); $validatorRules = ['type' => 'unique:resources', 'available' => 'integer', 'using' => 'integer', 'damaged' => 'integer']; $validator = Validator::make($data, $validatorRules, $this->validatorMessages); if ($validator->fails()) { $errorsMessages = $validator->errors()->all(); return response()->json(['message' => $errorsMessages[0]], 400); } else { $newResource = Resource::create($data); return response()->json($newResource); } }
public function seedResources() { Resource::create(['name' => 'Sala riunioni']); Resource::create(['name' => 'Coworking']); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(ResourceRequest $request) { Resource::create($request->only('name')); return redirect()->route('admin.resources.index'); }
/** * Process the creation form and store the new request. * @param \App\Http\Requests\ResourceRequest $request */ public function store(ResourceRequest $request) { // Create the resource $resource = Resource::create(['title' => $request->stripped('title'), 'description' => $request->has('description') ? $request->stripped('description') : null, 'category_id' => $request->has('category_id') ? $request->get('category_id') : null, 'event_id' => $request->has('event_id') ? $request->get('event_id') : null, 'author_id' => $this->user->id, 'type' => $request->get('type'), 'href' => null, 'access_id' => $request->has('access_id') ? $request->get('access_id') : null]); // Set the tags $resource->tags()->sync($request->has('tags') ? $request->get('tags') : []); // Upload the file if ($resource->isFile()) { $request->file('file')->move(Resource::getParentDirectory(), $resource->getFileName()); } else { if ($resource->isGDoc()) { $resource->update(['href' => $request->stripped('drive_id')]); } } Flash::success('Resource created'); return redirect(route('resources.view', ['id' => $resource->id])); }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('resources')->delete(); Resource::create(['seq' => '1', 'name' => 'my image', 'description' => 'my description', 'type' => 'image', 'url' => true, 'status' => 'active', 'image' => '', 'thumb' => '', 'content' => 'my content', 'published_at' => \Carbon\Carbon::now()]); }