I am trying to validate my user input which contains two input fields "title" and "description" after click on floating action button but I am getting an error when I do that.
notes_detail_widget.dart
class NoteDetailsWidgetState extends State<NoteDetailsWidget> {
final _formKey = new GlobalKey<FormState>();
String _title;
String _description;
_submit() {
if (_formKey.currentState.validate()) {
_formKey.currentState.save();
}
}
#override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text("Edit note data"),
),
body: new Form(
child: new Container(
margin: new EdgeInsets.all(16.0),
child: new Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
new Container(
child: new TextFormField(
decoration: new InputDecoration(
labelText: "Title",
border: InputBorder.none,
),
validator: (val) =>
val.isNotEmpty ? null : "Title must not be empty",
onSaved: (val) => _title = val),
),
new Container(
child: new Divider(
color: Colors.black,
)),
new TextFormField(
decoration: new InputDecoration(
labelText: "Description",
border: InputBorder.none,
),
keyboardType: TextInputType.multiline,
maxLines: 3,
validator: (val) =>
val.isNotEmpty ? null : "Description must not be empty",
onSaved: (val) => _description = val,
)
])),
),
floatingActionButton: new FloatingActionButton(
onPressed: () => _submit(), child: new Icon(Icons.check)),
);
}
}
Error Log:
I/flutter ( 8055): ══╡ EXCEPTION CAUGHT BY GESTURE ╞═══════════════════════════════════════════════════════════════════
I/flutter ( 8055): The following NoSuchMethodError was thrown while handling a gesture:
I/flutter ( 8055): The method 'validate' was called on null.
I/flutter ( 8055): Receiver: null
I/flutter ( 8055): Tried calling: validate()
I/flutter ( 8055):
I/flutter ( 8055): When the exception was thrown, this was the stack:
I/flutter ( 8055): #0 Object.noSuchMethod (dart:core/runtime/libobject_patch.dart:50:5)
I/flutter ( 8055): #1 NoteDetailsWidgetState._submit (package:notes_crud_app/note_details_widget.dart:16:31)
I/flutter ( 8055): #2 NoteDetailsWidgetState.build.<anonymous closure> (package:notes_crud_app/note_details_widget.dart:61:28)
I/flutter ( 8055): #3 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:507:14)
I/flutter ( 8055): #4 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:562:30)
I/flutter ( 8055): #5 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
I/flutter ( 8055): #6 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:242:9)
I/flutter ( 8055): #7 TapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:175:7)
I/flutter ( 8055): #8 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:315:9)
I/flutter ( 8055): #9 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:73:12)
I/flutter ( 8055): #10 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101:11)
I/flutter ( 8055): #11 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:180:19)
I/flutter ( 8055): #12 _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:158:22)
I/flutter ( 8055): #13 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:138:7)
I/flutter ( 8055): #14 _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:101:7)
I/flutter ( 8055): #15 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:85:7)
I/flutter ( 8055): #16 _invoke1 (dart:ui/hooks.dart:168:13)
I/flutter ( 8055): #17 _dispatchPointerDataPacket (dart:ui/hooks.dart:122:5)
I am quite new to both Dart and Flutter. Please guide.
you didn't add the form key inside the form
body:new Form(
key: _formKey,
child: new Column(
//rest of the code
)
),
Related
I am trying to add a different image to each key of my flatlist. However, the images aren't being showed on the screen by rendering the items, just the keys. The source of the images is correct, so as the name of the images. Can you find the mistake that I have made?
export default class HomeScreen extends React.Component {
constructor(props) {
super(props);
this.state = {
searchText: '',
};
}
render() {
//Data can be coming from props or any other source as well
const data = [
{
key: 'Athlean-X',
logo: 'athlean_x.png'
},
{
key: 'Panelaria Ricardo Faria',
logo: "euro2020.png"
},
{
key: 'tEsLa',
logo: "jamor.png"
},
{
key: 'Lols Inc.',
logo: "rock_in_rio.png"
},
{
key: 'Vale de Silicone',
logo: 'splash.png'
},
{
key: 'Empresa do Helder',
logo: "edp_cooljazz.png"
},
{
key: 'BD Swiss',
logo: "superbock_superrock.png"
}
];
const filteredData = this.state.searchText
? data.filter(x =>
x.key.toLowerCase().includes(this.state.searchText.toLowerCase())
)
: data;
return (
<View style={styles.container}>
<View style={styles.flatlist}>
<FlatList
data={filteredData}
renderItem={({ item }) => (
<View style={{flexDirection:'row'}}>
<Image
style={{width:50, height:50, alignSelf: 'center', borderRadius:300}}
source={{uri:item.logo}}
/>
<Text style={styles.item}>{item.key}</Text>
</View>
)}
/>
</View>
</View>
);
}
}
The images saved locally must be called using require function.
<FlatList
data={filteredData}
renderItem={({ item }) => (
<View style={{flexDirection:'row'}}>
<Image
style={{width:50, height:50, alignSelf: 'center', borderRadius:300}}
source={require(item.logo)}
/>
<Text style={styles.item}>{item.key}</Text>
</View>
)}
keyExtractor={item=>item.key}
/>
Flatlist requires every individual component in the list to have a unique key. That's why item.key is provided to key extractor.
Implementing paypal in my laravel 5.8 app
I got error :
Got Http response code 400 when accessing https://api.sandbox.paypal.com/v1/payments/payment/PAYID-NNNNNNNNNN/execute.
My control :
public function paypal_payment_execute()
{
// After Step 1
$apiContext = new \PayPal\Rest\ApiContext(
new \PayPal\Auth\OAuthTokenCredential(
'NNNNN', // ClientID
'NNNNN' // ClientSecret
)
);
$paymentId = request('paymentId');
$PayerID = request('PayerID');
$payment = Payment::get($paymentId, $apiContext);
$execution = new PaymentExecution();
$execution->setPayerId( $PayerID);
$transaction = new Transaction();
$amount = new Amount();
$details = new Details();
$details->setShipping(1.2)
->setTax(1.3)
->setSubtotal(17.50); //
$amount->setCurrency('USD');
$total_sum= 20; // I check this sum is setShipping + setTax + setSubtotal
$amount->setTotal( (integer)$total_sum);
$amount->setDetails($details);
$transaction->setAmount($amount);
$execution->addTransaction( [ $transaction ] ); // !!! I found that here must be an array?
try {
$result = $payment->execute($execution, $apiContext); // Number of error points at this line
} catch (Exception $pce) {
echo '<pre>::'.print_r( json_decode($pce->getData()) );
die("-1 XXZ app/Http/Controllers/PaymentController.php");
}
return $result;
}
I my browse I see output : https://prnt.sc/od3b6v
1) Can somebody say which kind of error is it ?
2) I see lines like :
$this->logger->info
Is it some logging ? Where can I look into it ?
3) That was very strange that error line was shown and not pre output in try catch block:
I expected to see pce->getData output:
} catch (Exception $pce) {
echo '<pre>::'.print_r( json_decode($pce->getData()) );
die("-1 XXZ app/Http/Controllers/PaymentController.php");
}
4) Searching I net I checked that making payment With JS code I set the same total and return urls, like :
<div id="paypal-button"></div>
<script src="https://www.paypalobjects.com/api/checkout.js"></script>
<script>
let total_sum= 20
alert( "-123 total_sum::"+(total_sum) )
paypal.Button.render({
// Configure environment
env: 'sandbox',
client: {
sandbox: 'NNNNN',
production: 'demo_production_client_id'
},
locale: 'en_US',
style: {
size: 'small',
color: 'blue',
shape: 'pill',
},
commit: true,
payment: function(data, actions) {
var payment = actions.payment.create({
"note_to_payer": "Contact us for any questions on your order.",
"intent": "sale",
"payer": {
"payment_method": "paypal"
},
redirect_urls : { //redirect_urls
return_url : '...paypal_payment',
cancel_url : '.../paypal_payment_cancel'
},
transactions: [{
amount: {
total: Number( total_sum ),
currency: 'USD'
}
}]
});
return payment;
},
onAuthorize: function(data, actions) {
return actions.payment.execute().then(function() {
return actions.redirect();
});
}
}, '#paypal-button');
</script>
How fix it ?
composer.json :
"type": "project",
"require": {
"php": "^7.1.3",
...
"laravel/framework": "5.8.*",
"paypal/rest-api-sdk-php": "*",
Modified :
No messages inside of PayPal\Exception\PPConnectionException block anyway.
In your link I noticed that currency code must be checked.
I created my account about 2 weeks ago : https://prnt.sc/od385x
Where can I check currency code (and maybe country ) ?
Is it in setting for any app ? I did not find where currency can be entered.
if any webhooks must be defoned? What are they for ?
I see “Upgrade to a business account” link . Can it be relative to my problem?
**Modified # 2:**
I attach error desctiption on my sercer in laravel.log when I got 400 error :
cat laravel.log :
[2019-07-12 07:30:33] local.ERROR: Got Http response code 400 when accessing https://api.sandbox.paypal.com/v1/payments/payment/PAYID-LUUDOCA2FR59365NU097882X/execute. {"userId":6,"exception":"[object] (PayPal\Exception\PayPalConnectionException(code: 400): Got Http response code 400 when accessing https://api.sandbox.paypal.com/v1/payments/payment/PAYID-LUUDOCA2FR59365NU097882X/execute. at /var/www/html/votes/vendor/paypal/rest-api-sdk-php/lib/PayPal/Core/PayPalHttpConnection.php:207)
[stacktrace]
#0 /var/www/html/votes/vendor/paypal/rest-api-sdk-php/lib/PayPal/Transport/PayPalRestCall.php(78): PayPal\Core\PayPalHttpConnection->execute('{\"payer_id\":\"Z9...')
#1 /var/www/html/votes/vendor/paypal/rest-api-sdk-php/lib/PayPal/Common/PayPalResourceModel.php(104): PayPal\Transport\PayPalRestCall->execute(Array, '/v1/payments/pa...', 'POST', '{\"payer_id\":\"Z9...', Array)
#2 /var/www/html/votes/vendor/paypal/rest-api-sdk-php/lib/PayPal/Api/Payment.php(650): PayPal\Common\PayPalResourceModel::executeCall('/v1/payments/pa...', 'POST', '{\"payer_id\":\"Z9...', NULL, Object(PayPal\Rest\ApiContext), Object(PayPal\Transport\PayPalRestCall))
#3 /var/www/html/votes/app/Http/Controllers/PaymentController.php(108): PayPal\Api\Payment->execute(Object(PayPal\Api\PaymentExecution), Object(PayPal\Rest\ApiContext))
#4 [internal function]: App\Http\Controllers\PaymentController->paypal_payment_execute()
#5 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array(Array, Array)
#6 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\Routing\Controller->callAction('paypal_payment_...', Array)
#7 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Route.php(219): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(App\Http\Controllers\PaymentController), 'paypal_payment_...')
#8 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Route.php(176): Illuminate\Routing\Route->runController()
#9 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Router.php(680): Illuminate\Routing\Route->run()
#10 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#11 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#12 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Routing\Middleware\SubstituteBindings->handle(Object(Illuminate\Http\Request), Object(Closure))
#13 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#14 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(75): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#15 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure))
#16 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#17 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#18 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#19 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#20 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(56): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#21 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#22 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#23 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#24 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))
#25 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#26 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(66): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#27 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
#28 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#29 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#30 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Router.php(682): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#31 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Router.php(657): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#32 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Router.php(623): Illuminate\Routing\Router->runRoute(Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route))
#33 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Router.php(612): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#34 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#35 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#36 /var/www/html/votes/vendor/proengsoft/laravel-jsvalidation/src/RemoteValidationMiddleware.php(53): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#37 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Proengsoft\JsValidation\RemoteValidationMiddleware->handle(Object(Illuminate\Http\Request), Object(Closure))
#38 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#39 /var/www/html/votes/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php(65): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#40 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Barryvdh\Debugbar\Middleware\InjectDebugbar->handle(Object(Illuminate\Http\Request), Object(Closure))
#41 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#42 /var/www/html/votes/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#43 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Fideloper\Proxy\TrustProxies->handle(Object(Illuminate\Http\Request), Object(Closure))
#44 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#45 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#46 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#47 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#48 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#49 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#50 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#51 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#52 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle(Object(Illuminate\Http\Request), Object(Closure))
#53 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#54 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(62): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#55 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#56 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#57 /var/www/html/votes/vendor/itsgoingd/clockwork/Clockwork/Support/Laravel/ClockworkMiddleware.php(29): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#58 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Clockwork\Support\Laravel\ClockworkMiddleware->handle(Object(Illuminate\Http\Request), Object(Closure))
#59 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#60 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#61 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#62 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#63 /var/www/html/votes/public/index.php(55): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#64 {main}
"}
Casn something be found in this error text?
It breaks my mind why try { block does not trigger...
I am trying to delete using ajax in laravel but it shows me error like 500 (Internal Server Error), i know its a token error but i am passing a token too still getting same error. without ajax i am able to delete a record.
Route:
Route::get('users/delete/{id}','UserController#destroy');
HTML
<button type="button" class="btn btn-sm btn-outline-danger js-sweetalert" data-token="{{ csrf_token() }}" data-id="{{$obj->id}}" title="Delete" data-type="confirm"><i class="fa fa-trash-o"></i></button>
<script>
$(function () {
$('.js-sweetalert').on('click', function (e) {
e.preventDefault();
var type = $(this).data('type');
var id = $(this).data('id');
var token = $(this).data("token");
var url = $(this).attr("data-link");
if (type === 'confirm') {
showConfirmMessage(id,token,url);
}
});
});
function showConfirmMessage(id,token,url) {
swal({
title: "Are you sure?",
text: "You will not be able to recover this imaginary file!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#dc3545",
confirmButtonText: "Yes, delete it!",
closeOnConfirm: false
}, function () {
$.ajax({
type: 'GET',
url: "http://localhost:82/reports.laravel.com/public/users/delete/"+id,
data: {
id: id,
_token: token
},
success: function (data) {
console.log("it Work");
if(data==true){
swal("Deleted!", "Your imaginary file has been deleted.", "success");
}
}
});
});
}
</script>
Controller:
class UserController extends Controller
{
public function destroy($id)
{
$user = User::find($id);
$deleted = $user->delete();
if($deleted){
return true;
}
}
}
Log:
[2018-09-19 09:58:18] local.ERROR: The Response content must be a string or object implementing __toString(), "boolean" given. {"userId":1,"email":"ansari#gmail.com","exception":"[object] (UnexpectedValueException(code: 0): The Response content must be a string or object implementing __toString(), \"boolean\" given. at C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\symfony\\http-foundation\\Response.php:394)
[stacktrace]
#0 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Http\\Response.php(45): Symfony\\Component\\HttpFoundation\\Response->setContent(true)
#1 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\symfony\\http-foundation\\Response.php(202): Illuminate\\Http\\Response->setContent(true)
#2 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(747): Symfony\\Component\\HttpFoundation\\Response->__construct(true)
#3 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(719): Illuminate\\Routing\\Router::toResponse(Object(Illuminate\\Http\\Request), true)
#4 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(679): Illuminate\\Routing\\Router->prepareResponse(Object(Illuminate\\Http\\Request), true)
#5 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(30): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#6 C:\\xampp\\htdocs\
eports.laravel.com\\app\\Http\\Middleware\\IsAdmin.php(21): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#7 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(151): App\\Http\\Middleware\\IsAdmin->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#8 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#9 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Auth\\Middleware\\Authenticate.php(43): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#10 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(151): Illuminate\\Auth\\Middleware\\Authenticate->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#11 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#12 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Middleware\\SubstituteBindings.php(41): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#13 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(151): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#14 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#15 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken.php(75): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#16 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(151): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#17 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#18 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\View\\Middleware\\ShareErrorsFromSession.php(49): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#19 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(151): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#20 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#21 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Session\\Middleware\\StartSession.php(63): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#22 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(151): Illuminate\\Session\\Middleware\\StartSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#23 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#24 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse.php(37): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#25 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(151): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#26 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#27 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Cookie\\Middleware\\EncryptCookies.php(66): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#28 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(151): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#29 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#30 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(104): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#31 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(681): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#32 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(656): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request))
#33 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(622): Illuminate\\Routing\\Router->runRoute(Object(Illuminate\\Http\\Request), Object(Illuminate\\Routing\\Route))
#34 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(611): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))
#35 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(176): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))
#36 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(30): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request))
#37 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\fideloper\\proxy\\src\\TrustProxies.php(57): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#38 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(151): Fideloper\\Proxy\\TrustProxies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#39 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#40 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php(31): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#41 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(151): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#42 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#43 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php(31): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#44 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(151): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#45 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#46 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize.php(27): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#47 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(151): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#48 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#49 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode.php(62): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#50 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(151): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#51 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#52 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(104): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#53 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(151): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#54 C:\\xampp\\htdocs\
eports.laravel.com\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(116): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#55 C:\\xampp\\htdocs\
eports.laravel.com\\public\\index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#56 {main}
"}
Change accordingly :
Route:
Route::delete('users/delete/{id}','UserController#destroy');
Controller:
class UserController extends Controller
{
public function destroy($id)
{
$deleted = User::find($id)->delete();
if($deleted){
return true;
}
}
}
HTML:
$.ajax({
type: 'DELETE',
url: "http://localhost:82/reports.laravel.com/public/users/delete/"+id,
data: {
"_token": "{{ csrf_token() }}",
"id": id
}
success: function (data) {
console.log("it Work");
if(data==true){
swal("Deleted!", "Your imaginary file has been deleted.", "success");
}
}
});
Add your token in data like this if it won't then please show the error
"_token": "{{ csrf_token() }}",
[2018-09-19 09:58:18] local.ERROR: The Response content must be a string or object implementing __toString(), "boolean" given. {"userId":1,"email":"ansari#gmail.com","exception":"[object] (UnexpectedValueException(code: 0): The Response content must be a string or object implementing __toString(), \"boolean\" given. at C:\\xampp\\htdocs\
eports.laravel.com\vendor\symfony\http-foundation\Response.php:394)
[stacktrace]
Regarding the error it's because you are returning a boolean true in your controller, because you are trigger the UserController#destroy controller with an ajax call, I will suggest you to do this
class UserController extends Controller
{
public function destroy(Request $request)
{
$user = User::findOrFail($id);
if($request->ajax()) {
$user->delete();
return response()->json(['deleted' =>> true, 'user' => $user]);
} else {
$user->delete();
return response()->setContent(true);
}
}
}
I'm trying to set the heightFactor of a dynamically sized Widget (for animation purposes), in this case a Text:
Stack(
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
FractionallySizedBox(
heightFactor: 0.5,
child: Text(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
),
),
],
),
Positioned.fill(
child: Center(
child: Text(
"Lorem ipsum".toUpperCase(),
),
),
),
],
);
that however results in the following exception:
I/flutter ( 7123): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter ( 7123): The following assertion was thrown during performLayout():
I/flutter ( 7123): BoxConstraints forces an infinite height.
I/flutter ( 7123): These invalid constraints were provided to RenderParagraph's layout() function by the following
I/flutter ( 7123): function, which probably computed the invalid constraints in question:
I/flutter ( 7123): RenderFractionallySizedOverflowBox.performLayout
I/flutter ( 7123): (package:flutter/src/rendering/shifted_box.dart:909:13)
I/flutter ( 7123): The offending constraints were:
I/flutter ( 7123): BoxConstraints(w=272.0, h=Infinity)
And wrapping the Text in either LimitedBox or ConstrainedBox seems to only change what the invalid constraints were provided to in the error message.
Nor does adding MainAxisSize.min to Column.mainAxisSize seem to make a difference.
Is there a way to accomplish this that avoids the error?
A FractionallySizedBox sizes itself to its parent. Because you're using a column within a stack it doesn't really have a limit on infinite height. Since infinity / 2 == infinity your text therefore also has an infinite height.
If you switch to using an align, you can size your object to the text rather than the parent.
For the update of my post table I want to add a validation to check if an image was uploaded. If no image is uploaded, everything is uploaded except the image, else it means there is an image and that is update.
I tried this in my Controller:
public function update(Request $request, $id)
{
if(request('photo')){
$exploded = explode(',', request('photo'));
$decoded = base64_decode($exploded[1]);
if(str_contains($exploded[0], 'jpeg'))
$extension = 'jpg';
else
$extension = 'png';
$fileName = str_random().'.'.$extension;
$path = public_path().'/'.$fileName;
file_put_contents($path, $decoded);
$post = Post::findOrFail($id);
$post->title = request('title');
$post->description = request('description');
$post->category_id = request('category_id');
$post->user_id = Auth::id();
$post->photo = $fileName;
$post->save();
}
else{
$post = Post::findOrFail($id);
$post->title = request('title');
$post->description = request('description');
$post->category_id = request('category_id');
$post->user_id = Auth::id();
$post->save();
}
return response()->json([
'post' => $post,
], 200);
}
In my vue file I have the following:
editPost(){
if(this.update_post.photo == ''){
axios.put('/api/posts/' + this.update_post.id, {
title: this.update_post.title,
description: this.update_post.description,
category_id: this.update_post.category_id
})
.then(response => {
alert('updated');
this.showPosts();
})
.catch(function(error){
console.log(error);
});
}
else{
axios.put('/api/posts/' + this.update_post.id, {
title: this.update_post.title,
description: this.update_post.description,
category_id: this.update_post.category_id,
photo: this.update_post.photo
})
.then(response => {
alert('updated');
this.showPosts();
})
.catch(function(error){
console.log(error);
});
}
}
When I try to update a post, if no image is inserted I get 500 Internal server error:
app.js:14233 PUT http://myblog.local/api/posts/52 500 (Internal Server Error)
The below are some of the errors I see in the error log:
[2018-06-27 20:55:48] local.ERROR: Undefined offset: 1 {"userId":11,"email":"sidney#lab.com","exception":"[object] (ErrorException(code: 0): Undefined offset: 1 at C:\\xampp\\htdocs\\sidneyblog\\app\\Http\\Controllers\\AdminPostsController.php:66)
[stacktrace]
#0 C:\\xampp\\htdocs\\sidneyblog\\app\\Http\\Controllers\\AdminPostsController.php(66): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(8, 'Undefined offse...', 'C:\\\\xampp\\\\htdocs...', 66, Array)
#1 [internal function]: App\\Http\\Controllers\\AdminPostsController->update(Object(Illuminate\\Http\\Request), '53')
#2 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Controller.php(54): call_user_func_array(Array, Array)
#3 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction('update', Array)
#4 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php(212): Illuminate\\Routing\\ControllerDispatcher->dispatch(Object(Illuminate\\Routing\\Route), Object(App\\Http\\Controllers\\AdminPostsController), 'update')
#5 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php(169): Illuminate\\Routing\\Route->runController()
#6 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(665): Illuminate\\Routing\\Route->run()
#7 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(30): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#8 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Middleware\\SubstituteBindings.php(41): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#9 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(151): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#10 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#11 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken.php(67): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#12 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(151): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#13 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#14 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\View\\Middleware\\ShareErrorsFromSession.php(49): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#15 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(151): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#16 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#17 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Session\\Middleware\\StartSession.php(63): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#18 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(151): Illuminate\\Session\\Middleware\\StartSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#19 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#20 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse.php(37): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#21 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(151): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#22 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#23 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Cookie\\Middleware\\EncryptCookies.php(59): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#24 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(151): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#25 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#26 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(104): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#27 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(667): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#28 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(642): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request))
#29 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(608): Illuminate\\Routing\\Router->runRoute(Object(Illuminate\\Http\\Request), Object(Illuminate\\Routing\\Route))
#30 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(597): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))
#31 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(176): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))
#32 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(30): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request))
#33 C:\\xampp\\htdocs\\sidneyblog\\vendor\\fideloper\\proxy\\src\\TrustProxies.php(57): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#34 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(151): Fideloper\\Proxy\\TrustProxies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#35 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#36 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php(31): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#37 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(151): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#38 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#39 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php(31): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#40 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(151): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#41 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#42 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize.php(27): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#43 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(151): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#44 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#45 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode.php(51): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#46 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(151): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#47 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#48 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(104): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#49 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(151): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#50 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(116): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#51 C:\\xampp\\htdocs\\sidneyblog\\public\\index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#52 {main}
"}
How can I fix that?
In your controller, the condition if(request('photo')) is always true.
To Retrieving Input from the request use Request $request variable. for example:
for file: $request->file('photo');
for other text: $request->input('description');