mercredi 15 juillet 2020

Creating default object from empty value?

Admin Controller

public function edit_portal_sub(Request $request)
    {
        $portal=Oex_portal::where('id',$request->id)->get()->first();
        $portal->name=$request->name;
        $portal->email=$request->email;
        $portal->mobile_no=$request->mobile_no;
        if($request->password!='')
            $portal->password=$request->password;
        $portal->update();
        echo json_encode(array('status'=>'true','message'=>'Portal Successfully Updated','reload'=>url('admin/manage_portal')));
    }

web.php(route)

Route::post('/admin/edit_portal_sub','Admin@edit_portal_sub');

edit_portal.blade(form)

@extends('layouts.app')
@section('title','Edit Portal')
@section('content')
    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <div class="content-header">
            <div class="container-fluid">
                <div class="row mb-2">
                    <div class="col-sm-6">
                        <h1 class="m-0 text-dark">Edit Portal</h1>
                    </div><!-- /.col -->
                    <div class="col-sm-6">
                        <ol class="breadcrumb float-sm-right">
                            <li class="breadcrumb-item"><a href="#">Home</a></li>
                            <li class="breadcrumb-item active">Edit Portal</li>
                        </ol>
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.container-fluid -->
        </div>
        <!-- /.content-header -->
        <section class="content">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-12">
                        <!-- Default box -->
                        <div class="card">
                            <div class="card-body">
                                <form action=" " class="database_operation">
                                    <div class="row">
                                        <div class="col-sm-12">
                                            <div class="form-group">
                                                <label>Enter Name</label>
                                                
                                                <input type="hidden" name="id" value="">
                                                <input type="text" value="" name="name" required="required" placeholder="Enter Name" class="form-control">
                                            </div>
                                        </div>
                                        <div class="col-sm-12">
                                            <div class="form-group">
                                                <label>Enter Email</label>
                                                <input type="text" value="" name="email" required="required" placeholder="Enter Email" class="form-control">
                                            </div>
                                        </div>
                                        <div class="col-sm-12">
                                            <div class="form-group">
                                                <label>Enter Mobile No</label>
                                                <input type="text" value="" name="mobile_no" required="required" placeholder="Enter Mobile No" class="form-control">
                                            </div>
                                        </div>
                                        <div class="col-sm-12">
                                            <div class="form-group">
                                                <label>Enter Password</label>
                                                <input type="password" name="password"  placeholder="Enter Password" class="form-control">
                                            </div>
                                        </div>
                                        <div class="col-sm-12">
                                            <div class="form-group">
                                                <button class="btn btn-primary"> Update</button>
                                            </div>
                                        </div>
                                    </div>
                                </form>
                            </div>
                            <!-- /.card-body -->

                            <!-- /.card-footer-->
                        </div>
                        <!-- /.card -->
                    </div>
                </div>
            </div>
        </section>
    </div>
@endsection

when am update data am face that error Error

message: "Creating default object from empty value"
trace: [{file: "C:\xampp\htdocs\project\online_exm_sys\app\Http\Controllers\Admin.php", line: 243,…},…]
0: {file: "C:\xampp\htdocs\project\online_exm_sys\app\Http\Controllers\Admin.php", line: 243,…}
1: {function: "edit_portal_sub", class: "App\Http\Controllers\Admin", type: "->"}

when am update data and inspect the page i show error i cant understad how to solve it...plz help am new laravel user ...what is its best solution am stuck for this error 2 days..i try every possible solution



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire