本文整理汇总了PHP中request::hasFile方法的典型用法代码示例。如果您正苦于以下问题:PHP request::hasFile方法的具体用法?PHP request::hasFile怎么用?PHP request::hasFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类request
的用法示例。
在下文中一共展示了request::hasFile方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateStore
public function updateStore(request $request)
{
$validator = Validator::make($request->all(), ['store_id' => 'required', 'store_name' => 'required|max:255', 'landline' => 'required', 'cost_two' => 'required', 'veg' => 'required', 'status' => 'required', 'street' => 'required|max:200', 'area_id' => 'required', 'city_id' => 'required', 'state_id' => 'required', 'country_id' => 'required', 'pincode' => 'required', 'latitude' => 'required', 'longitude' => 'required']);
$input = $request->only('store_id');
if ($validator->fails()) {
return redirect('admin/store/' . $input["store_id"] . '/edit')->withErrors($validator);
}
$store = MerchantStore::find($input['store_id']);
foreach ($request->only('store_name', 'cost_two', 'veg', 'landline', 'status') as $key => $value) {
$store->{$key} = $value;
}
if ($request->hasFile('logo')) {
$image = $request->file('logo');
$imageName = strtotime(Carbon::now()) . md5($input['store_id']) . '.' . $image->getClientOriginalExtension();
$path = public_path('assets/img/stores/' . $imageName);
Image::make($image->getRealPath())->resize(280, null, function ($constraint) {
$constraint->aspectRatio();
})->save($path);
$store->logoUrl = $imageName;
}
$store->save();
$store->tags()->detach();
$tags = $request->only('tags');
$tagStore = explode(',', $tags['tags']);
$store->tags()->attach($tagStore);
$matchThese = ['store_id' => $input['store_id']];
$address = MerchantStoreAddress::where($matchThese)->first();
foreach ($request->only('street', 'area_id', 'city_id', 'state_id', 'country_id', 'pincode', 'latitude', 'longitude') as $key => $value) {
$address->{$key} = $value;
}
$address->save();
return redirect('admin/store/' . $input['store_id']);
}
示例2: editProfile
public function editProfile(request $request)
{
$rules = array('email' => 'unique:users');
$validator = $this->customValidator($request->all(), $rules, array());
if ($validator->fails()) {
return response()->json(['response_code' => 'ERR_EAE', 'message' => 'Email Already Exists'], 409);
}
$user_id = Auth::user()->id;
$user = User::find($user_id);
foreach ($request->only('name', 'email') as $key => $value) {
$user->{$key} = $value;
}
if ($request->hasFile('profileImg')) {
$image = $request->file('profileImg');
$imageName = strtotime(Carbon::now()) . md5($user_id) . '.' . $image->getClientOriginalExtension();
$path = public_path('assets/img/users/' . $imageName);
Image::make($image->getRealPath())->resize(280, 240)->save($path);
$user->profileImg = $imageName;
}
$user->save();
return response()->json(['response_code' => 'RES_UU', 'messages' => 'User Upadated', 'data' => $user]);
}
示例3: editStore
public function editStore(request $request)
{
$store_id = Auth::user()->stores->id;
$store = MerchantStore::find($store_id);
foreach ($request->only('store_name', 'cost_two', 'status', 'landline', 'veg', 'description') as $key => $value) {
$store->{$key} = $value;
}
if ($request->hasFile('logo')) {
$image = $request->file('logo');
$imageName = strtotime(Carbon::now()) . md5($store_id) . '.' . $image->getClientOriginalExtension();
$path = public_path('assets/img/stores/' . $imageName);
Image::make($image->getRealPath())->resize(280, null, function ($constraint) {
$constraint->aspectRatio();
})->save($path);
$store->logoUrl = $imageName;
}
$store->save();
$store->tags()->detach();
$tags = $request->only('tags');
$tagStore = explode(',', $tags['tags']);
$store->tags()->attach($tagStore);
$matchThese = ['store_id' => $store_id];
$address = MerchantStoreAddress::where($matchThese)->first();
foreach ($request->only('street', 'area_id', 'city_id', 'state_id', 'country_id', 'pincode', 'latitude', 'longitude') as $key => $value) {
$address->{$key} = $value;
}
$address->save();
$output = ['store' => $store, 'address' => $address];
return response()->json(['response_code' => 'RES_SU', 'messages' => 'Store Upadated', 'data' => $output]);
}
示例4: updateStore
public function updateStore(request $request)
{
$validator = Validator::make($request->all(), ['store_id' => 'required', 'name' => 'required|max:255', 'address' => 'required|min:10', 'code' => 'required', 'cost' => 'required', 'timer' => 'required|max:200', 'is_active' => 'required']);
$input = $request->only('store_id');
$inputVal = $request->only('name', 'code');
if ($validator->fails()) {
return redirect('admin/store/' . $input["store_id"] . '/edit')->withErrors($validator);
}
$store = Store::find($input['store_id']);
if ($inputVal['name'] != $store->name) {
$validator = Validator::make($request->all(), ['name' => 'unique:stores']);
if ($validator->fails()) {
return redirect('admin/store/' . $input["store_id"] . '/edit')->withErrors($validator);
}
}
if ($inputVal['code'] != $store->code) {
$validator = Validator::make($request->all(), ['code' => 'unique:stores']);
if ($validator->fails()) {
return redirect('admin/store/' . $input["store_id"] . '/edit')->withErrors($validator);
}
}
foreach ($request->only('name', 'address', 'code', 'cost', 'timer', 'is_active') as $key => $value) {
$store->{$key} = $value;
}
if ($request->hasFile('offer_image')) {
$image = $request->file('offer_image');
$imageName = strtotime(Carbon::now()) . md5($input['store_id']) . '.' . $image->getClientOriginalExtension();
$path = public_path('assets/img/stores/' . $imageName);
Image::make($image->getRealPath())->resize(280, 240)->save($path);
$store->offer_image = $imageName;
}
$store->save();
return redirect('admin/store/' . $input['store_id']);
}
示例5: editStore
public function editStore(request $request)
{
$store_id = $request->only('store_id');
if (!$this->checkUserHasStore($store_id['store_id'], false)) {
return response()->json(['response_code' => 'ERR_UNA', 'messages' => 'User Not Authorized'], 403);
}
$store = MerchantStore::find($store_id['store_id']);
foreach ($request->only('store_name', 'description', 'cost_two', 'status') as $key => $value) {
$store->{$key} = $value;
}
if ($request->hasFile('logo')) {
$image = $request->file('logo');
$imageName = strtotime(Carbon::now()) . md5($input['store_id']) . '.' . $image->getClientOriginalExtension();
$path = public_path('assets/img/stores/' . $imageName);
Image::make($image->getRealPath())->resize(280, 240)->save($path);
$store->logoUrl = $imageName;
}
$store->save();
$store->tags()->detach();
$tags = $request->only('tags');
$tagStore = explode(',', $tags['tags']);
$store->tags()->attach($tagStore);
$matchThese = ['store_id' => $store_id['store_id']];
$address = MerchantStoreAddress::where($matchThese)->first();
foreach ($request->only('street', 'city_id', 'state_id', 'country_id', 'pincode', 'latitude', 'longitude') as $key => $value) {
$address->{$key} = $value;
}
$address->save();
$output = ['store' => $store, 'address' => $address];
return response()->json(['response_code' => 'RES_SU', 'messages' => 'Store Upadated', 'data' => $output]);
}
示例6: postApplyForTravel
public function postApplyForTravel(request $request)
{
$travelRequested = "";
if (isset($_POST['OfficialBusinesswithAirfare']) == true && $_POST['OfficialBusinesswithAirfare'] == true) {
$travelRequested .= "Official Business with Airfare,";
}
if (isset($_POST['officialTime']) == true && $_POST['officialTime'] == true) {
$travelRequested .= "Official time,";
}
if ($travelRequested != "") {
$travelRequested = rtrim($travelRequested, ",");
}
$applicationEntitlements = "";
if (isset($_POST['entitlementrequestedInternationalAirfare'])) {
$applicationEntitlements .= "International airfare (economy);";
}
if (isset($_POST['entitlementrequestedTravelAllowance'])) {
$applicationEntitlements .= 'Travel allowance;';
}
if (isset($_POST['entitlementrequestedRegistrationParticipationFee'])) {
$applicationEntitlements .= 'Registration fee / participation fee;';
}
if (isset($_POST['entitlementrequestedOthers'])) {
$applicationEntitlements .= "others;";
}
$travelType = "";
if (isset($_POST['officialTime'])) {
$travelType .= 'OTO;';
}
if (isset($_POST['OfficialBusinesswithAirfare'])) {
$travelType .= 'OB;';
}
if (isset($_POST['OfficialLeaveOfAbsence'])) {
$travelType .= 'OLA;';
}
if (isset($_POST['travelType'])) {
$travelType = $_POST['travelType'];
}
$administrativeRequirement = "";
if (isset($_POST['administrativeRequirements'])) {
$administrativeRequirement = $_POST['administrativeRequirements'];
}
$municipality = isset($_POST['municipality']) ? $_POST['municipality'] : "";
$insert = ['applicationstatus_id' => 1, 'remarks' => "", 'region' => trim(Auth::user()->region), 'province' => trim($_POST['selectprovince']), 'municipality' => $municipality, 'firstname' => trim($_POST['firstname']), 'lastname' => trim($_POST['lastname']), 'middlename' => trim($_POST['middlename']), 'sex' => trim($_POST['sex']), 'suffix' => trim($_POST['suffix']), 'birthdate' => $_POST['birthdate'], 'positionType' => $_POST['positionType'], 'position' => $_POST['positionType'] == "NON ELECTIVE" ? $_POST['nonelectiveposition'] : $_POST['position'], 'picture' => 'pictures/' . $_FILES['picture']['name'], 'mobile' => $_POST['mobilenumber'], 'travelType' => $travelType, 'groupDelegation' => $_POST['groupDelegation'], 'benefits' => $_POST['benefits'], 'created_at' => date("Y-m-d H:i:s"), 'email' => $_POST['email'], 'encodedBy' => Auth::user()->lastname . ", " . Auth::user()->firstname . ", " . Auth::user()->middlename];
//todo: add some back-end validation
if (isset($_POST['apply'])) {
$travel = travelApplication::create($insert);
$this->travelApplication_id = $travel->id;
if ($travel->id) {
$travelApplication_id = $travel->id;
$this->travelApplication_id = $travel->id;
$flights = [];
foreach ($_POST['travel_flight'] as $travel_i) {
array_push($flights, ["country" => $travel_i["country"], "datefrom" => $travel_i["datefrom"], "dateto" => $travel_i["dateto"], "benefits" => $travel_i["benefits"], "groupdelegation" => $travel_i["groupdelegation"], "natureoftravelrequested" => $travel_i["natureoftravelrequested"], "traveltype" => $travel_i["traveltype"], "entitlementsrequested" => $travel_i["entitlementsrequested"], "undertravelallowance" => $travel_i["undertravelallowance"]]);
}
foreach ($flights as $flight) {
$travel_insert = ["country" => $flight["country"], "datefrom" => $flight["datefrom"], "travelapplication_id" => $travel->id, "dateto" => $flight["dateto"], "benefits" => $flight["benefits"], "groupdelegation" => $flight["groupdelegation"], "natureoftravelrequested" => $flight["natureoftravelrequested"], "traveltype" => $flight["traveltype"], "entitlementsrequested" => $flight["entitlementsrequested"], "undertravelallowance" => $flight["undertravelallowance"]];
$travel_flight_insert = travelflight::create($travel_insert);
}
//upload picture
if ($request->hasFile('picture')) {
//
$request->file('picture')->move('pictures/', $request->file('picture')->getClientOriginalName());
} else {
die("error uploading picture");
exit;
}
//upload updated pic
if ($request->hasFile('updatedPicture')) {
//upload updated picture
$request->file('updatedPicture')->move('documents/', $request->file('updatedPicture')->getClientOriginalName());
$attachedUpdatedPicture = new attachedDocuments();
$attachedUpdatedPicture->name = $request->file('updatedPicture')->getClientOriginalName();
$attachedUpdatedPicture->location = 'documents/' . $request->file('updatedPicture')->getClientOriginalName();
$attachedUpdatedPicture->travelApplication_id = $this->travelApplication_id;
$attachedUpdatedPicture->created_at = date("Y-m-d");
$attachedUpdatedPicture->categories = "updated picture";
$attachedUpdatedPicture->save();
}
//upload docs
if ($request->hasFile('documents')) {
//
for ($i = 0; $i <= count($request->file('documents')) - 1; $i++) {
if ($request->file('documents')[$i]) {
$request->file('documents')[$i]->move('documents/', $request->file('documents')[$i]->getClientOriginalName());
$attachedDocument = new attachedDocuments();
$attachedDocument->name = $request->file('documents')[$i]->getClientOriginalName();
$attachedDocument->location = 'documents/' . $request->file('documents')[$i]->getClientOriginalName();
$attachedDocument->travelApplication_id = $this->travelApplication_id;
$attachedDocument->created_at = date("Y-m-d");
$attachedDocument->remarks = $request->documentremarks[$i];
$attachedDocument->save();
}
}
} else {
// die("error uploading document(s)");
// exit();
}
//upload docs
return redirect('home');
//.........这里部分代码省略.........