adamjhn

Experience

3,740

0 Best Reply Awards

  • Member Since 1 Month Ago
  • 0 Lessons Completed
  • 0 Favorites

26th May, 2018

adamjhn left a reply on Stripe Integration- Console Shows Not Defined Error • 7 hours ago

Do you know if its used the StripeCheckout function like:

let stripe = StripeCheckout.configure({
                key: "{{config('pk_test_...')}}",
                locale: "auto",
                token: (token) => {
                    document.querySelector('#stripeToken').value = token.id;
                    document.querySelector('#paymentForm').submit();
                }

            });

it appears:

Uncaught ReferenceError: StripeCheckout is not defined
    at HTMLDocument.<anonymous> (registration:588)

adamjhn left a reply on Stripe Integration- Console Shows Not Defined Error • 8 hours ago

Thanks for the explanation!

adamjhn left a reply on Stripe Integration- Console Shows Not Defined Error • 8 hours ago

Thanks, can you explain better that part of dont have js in blade views? Your are saying that instead of have the necessary js for a specific blade view like for example:

@section('scripts')

        $(function () {
            // js code for this specific view
                
        });
@endsection

Have just imports of js files that are necessary for that specific view like:

@section('scripts')

<script type="text/javascript" src="{{url('js/getConferencesAjax.js')}}"></script>
 <script type="text/javascript" src="{{url('js/searchConferencesAjax.js')}}"></script>

@endsection

adamjhn left a reply on Stripe Integration- Console Shows Not Defined Error • 8 hours ago

The code is in a blade view. But above the form there is the " ".

adamjhn left a reply on Stripe Integration- Console Shows Not Defined Error • 8 hours ago

Thanks! Now it appears "Uncaught SyntaxError: Unexpected token &". Do you know why?

adamjhn left a reply on Stripe Integration- Console Shows Not Defined Error • 8 hours ago

Thanks but shows the same error using "" like:

var stripe = Stripe({{config("pk_test_...")}});

adamjhn left a reply on Stripe Integration- Console Shows Not Defined Error • 9 hours ago

If I pass the key directly like:

           var stripe = Stripe({{config('pk_....')}});
It shows:

jquery.min.js:2 Uncaught Error: Invalid value for Stripe(): apiKey should be a string. You specified: undefined.

adamjhn left a reply on Stripe Integration- Console Shows Not Defined Error • 9 hours ago

Thanks, but to test is not better to use the test key?

adamjhn started a new conversation Stripe Not Defined Error • 9 hours ago

Do you know why is appearing the error below using the default stripe code in the documentation?

jquery.min.js:2 Uncaught ReferenceError: pk_test_.... is not defined
    at HTMLDocument.<anonymous> (registration:607)

Laravel RegistrationController charge():

 public function charge(Request $request)
    {
        Stripe::setApiKey(config('services.stripe.secret'));
        $source = $request->stripeToken;

            Charge::create([
                'currency' => 'eur',
                'description' => 'Example charge',
                'amount' => 2500,
                'source' => $source,
            ]);
    }

Html:


<script src="https://js.stripe.com/v3/"></script>

<form action="{{ route('registration.charge') }}" method="post" id="payment-form">
    {{csrf_field()}}

    <div class="form-row">
        <label for="card-element">
            Credit or debit card
        </label>
        <div id="card-element">
            <!-- A Stripe Element will be inserted here. -->
        </div>

        <!-- Used to display form errors. -->
        <div id="card-errors" role="alert"></div>
    </div>

    <button>Submit Payment</button>
</form>

Stripe js:

var stripe = Stripe({{config('services.stripe.key')}});

// Create an instance of Elements.
var elements = stripe.elements();

// Custom styling can be passed to options when creating an Element.
// (Note that this demo uses a wider set of styles than the guide below.)
var style = {
    base: {
        color: '#32325d',
        lineHeight: '18px',
        fontFamily: '"Helvetica Neue", Helvetica, sans-serif',
        fontSmoothing: 'antialiased',
        fontSize: '16px',
        '::placeholder': {
            color: '#aab7c4'
        }
    },
    invalid: {
        color: '#fa755a',
        iconColor: '#fa755a'
    }
};

// Create an instance of the card Element.
var card = elements.create('card', {style: style});

// Add an instance of the card Element into the `card-element` <div>.
card.mount('#card-element');

// Handle real-time validation errors from the card Element.
card.addEventListener('change', function(event) {
    var displayError = document.getElementById('card-errors');
    if (event.error) {
        displayError.textContent = event.error.message;
    } else {
        displayError.textContent = '';
    }
});

// Handle form submission.
var form = document.getElementById('payment-form');
form.addEventListener('submit', function(event) {
    event.preventDefault();

    stripe.createToken(card).then(function(result) {
        if (result.error) {
            // Inform the user if there was an error.
            var errorElement = document.getElementById('card-errors');
            errorElement.textContent = result.error.message;
        } else {
            // Send the token to your server.
            stripeTokenHandler(result.token);
        }
    });
});

adamjhn started a new conversation Type Error: Argument 1 Passed To Illuminate\Auth\SessionGuard::login() Must Implement Interface Illuminate\Contracts\Auth\Authenticatable • 15 hours ago

I have the controllers below to allow the user login with laravel auth system but also to login with facebook using socialite.

But when the user clicks in the button "Login with facebook" it appears this error:

  Type error: Argument 1 passed to Illuminate\Auth\SessionGuard::login() must implement interface Illuminate\Contracts\Auth\Authenticatable, string given, called in AuthManager.php on line 292.

The user is stored in the database but that error appears. Do you know why?

Do you know why?

  class OauthController extends Controller
  {
      
      public function redirectToProvider($provider)
      {
          return Socialite::driver($provider)->redirect();
  
      }
  
      public function handleProviderCallback($provider)
      {
          $userFace = Socialite::driver($provider)->user();
  
          $findUser = User::where('email', $userFace->email)->first();
  
          if($findUser){
              Auth::login($findUser);
          }else{
              $user = new User;
              $user->name = $userFace->name;
              $user->surname = "";
              $user->email = $userFace->email;
              $user->password = bcrypt($user->name);
              $user->save();
              Auth::login($userFace->email);
          }
      }
  }

AuthController:

  class AuthController extends Controller
  {
      public function login(){
  
          if(\Input::has('code')){
          }
          return \Socialite::with('facebook')->redirect();
      }
  }

LoginController:

  class LoginController extends Controller
  {
    
      use AuthenticatesUsers;
  
      protected $redirectTo = '/';
  
      public function __construct()
      {
          $this->middleware('guest')->except('logout');
      }
  
      protected function redirectTo()
      {
          if(Route::getRoutes()->match(Request::create(\URL::previous()))->getName() == "cong.reg") {
              return (Request::create(\URL::previous())->getRequestUri());
          }
          return $this->redirectTo;
      }
  }

adamjhn left a reply on Do You Know Why The Request Data Is Not Appaering? • 16 hours ago

Thanks, do you know how to click in the pay button and open the modal in the same page instead of redirect?

adamjhn left a reply on Do You Know Why The Request Data Is Not Appaering? • 16 hours ago

Thanks, but it should response with the token to use for the charge right?

adamjhn started a new conversation Do You Know Why The Request Data Is Not Appaering? • 17 hours ago

I have a form using stripe. When the pay button is clicked instead of a modal appears in the same page the user is redirected to another page "https://checkout.stripe.com/v3/....html?distinct_id=..." and the modal appears in that page. Do you know why?

The "dd($request->al());" in the [email protected] is not showing nothing. In the network tab appears:

Request URL: https://q.stripe.com/?event=checkout.config.summary&rf=....? and also appears status code 200.

But the "dd($request->al());" dont appears. Do you know why?

    <form action="{{ route('registration.charge') }}" method="post">
        {{csrf_field()}}
            <script
                    src="https://checkout.stripe.com/checkout.js"
                    class="stripe-button"
                    data-key="pk_test.."
                    data-image="/square-image.png"
                    data-name="Demo Site"
                    data-description="2 widgets (.00)"
                    data-amount="2000"
                    data-image="">
            </script>
    
        <button type="button" href="#step3" data-toggle="tab" role="tab"
                class="btn btn-outline-primary prev-step mr-2">
           Go back to step 2
        </button>
    </form>

I have the route:

    Route::post('/charge', [
        'uses' => '[email protected]',
        'as'   => 'registration.charge'
    ]);

In the RegistrationController there is:

    public function charge(Request $request){
        dd($request->all());
    }

25th May, 2018

adamjhn left a reply on Show Custom Questions With The Appropriate Type (text, Checkbox, Select, Etc) Is Not Workign Properly • 1 day ago

It seems that is necessary to put $option->value instead of $name like:

                    $str .= "<label><input type='checkbox' name='$name' class='$class''" . ($required?:"required") . "> ". $option->value ." </label>";

adamjhn left a reply on Show Custom Questions With The Appropriate Type (text, Checkbox, Select, Etc) Is Not Workign Properly • 1 day ago

Thanks, but like that it appaers like the left screen of the image "https://ibb.co/fZsyqo" instead of appear like the right screen of the image, do you know why?

adamjhn left a reply on Show Custom Questions With The Appropriate Type (text, Checkbox, Select, Etc) Is Not Workign Properly • 1 day ago

Thanks, but in the quesiton example with "checkbox". This seems correct:

case "checkbox":
                    return "<input type='".($customtype?:"checkbox")."' name='$name' class='$class''" . ($required?:"required") . ">";

But the checkbox dont appears properly as it is visible in the question 3 of the image.

24th May, 2018

adamjhn started a new conversation Show Custom Questions With The Appropriate Type (text, Checkbox, Select, Etc) Is Not Workign Properly • 2 days ago

I have a form for a user create custom questions. For that the user needs to introduce the question and also the type of field (text, long text, checkbox, select menu, radio button).

For example if the user can create a custom question "Receive newsletter?" and select the type "Checkbox" and sselect the options for the checkboxes like "yes" and "no" and click "Create question".

In the database is inserted in the questions and question_options tables like:

questions table:

    id     question                    type          conference_id      
    1        Receive notiications?     checkbox             1

question_options table:

    id     question_id                   type                
    1       1                          yes       
    2       1                          no      

My doubt is how to show properly in the registration.blade.php the inputs (text, radio button, checkbox, select, textarea and input file) based on the type stored in the column "type" of the questions table. For now is not working properly it is appearing like the left screen of the image but should appear like the right screen of the image:

https://ibb.co/fddQLo

Do you know why is not appearing like the the right screen of the image?

In the Questions model there is this getHtmlInput method():

    public function getHtmlInput($name = "", $val = "", $required = false, $class = "", $customtype=false)
        {
            switch ($this->type) {
                case "text":
                      return "<input type='".($customtype?:"text")."' name='$name' val='$val' class='$class''" . ($required?:"required") . ">";
                case "checkbox":
                    return "<input type='".($customtype?:"checkbox")."' name='$name' class='$class''" . ($required?:"required") . ">";
                case "radio_btn":
                    return "<input type='".($customtype?:"radio")."' name='$name' class='$class''" . ($required?:"required") . ">";
                case "select_menu":
                    return "<input type='".($customtype?:"radio")."' name='$name' class='$class''" . ($required?:"required") . ">";
                case "textarea":
                    return "<input type='".($customtype?:"radio")."' name='$name' class='$class''" . ($required?:"required") . ">";
            }
        }

In the registration.blade.php the questions are presented with the code below:

    @if ($allParticipants == 0)
        @foreach($selectedRtype['questions'] as $customQuestion)
            <div class="form-group">
                <label for="participant_question">{{$customQuestion->question}}</label>
                {!! $customQuestion->getHtmlInput(
                'participant_question[]',($customQuestion->pivot->required == "1") ? 'required' : '',
                $class = "form-control",
                 $customtype=$customQuestion->type) !!}
            </div>
            @if($customQuestion->hasOptions())
                @foreach($customQuestion->options as $option)
                    <p>{{ $option->value }}</p>
                @endforeach
            @endif
        @endforeach
    @endif     

QuestionController store method to create question:

    public function store(Request $request, $id){
        $this->validate($request, [
            'question' => 'required|max:255|string',
            'type' => 'required|max:255|string',
        ]);
        $conference = Conference::find($id);
        $question = Question::create([
            'conference_id' => $conference->id,
            'question' => $request->question,
            'type' => $request->type,
        ]);
    
    
        if(in_array($request->type, Question::$typeHasOptions)){
            foreach($request->input('questionOptions') as $questionOption) {
                QuestionOption::create([
                    'question_id' => $question->id,
                    'value' => $questionOption
                ]);
            }
        }
        Session::flash('success', 'Question created with success.');
        return redirect()->back();
    }

Models:

// Question model

    class Question extends Model
    {
        protected $fillable = [
            'question', 'type', 'conference_id',
        ];
    
        public static $typeHasOptions = [
            'radio_btn',
            'select_menu',
            'checkbox'
        ];
    
        public function ticket_types(){
            return $this->belongsToMany('App\TicketType', 'ticket_type_questions')
                ->withPivot('required');
        }
    
        public function options() {
            return $this->hasMany('App\QuestionOption');
        }
    
    
        public function hasOptions() {
            return in_array($this->type, self::$typeHasOptions);
        }
    
        public function getHtmlInput($name = "", $val = "", $required = false, $class = "", $customtype=false)
        {
            switch ($this->type) {
                case "text":
                      return "<input type='".($customtype?:"text")."' name='$name' val='$val' class='$class''" . ($required?:"required") . ">";
                case "checkbox":
                    return "<input type='".($customtype?:"checkbox")."' name='$name' class='$class''" . ($required?:"required") . ">";
                case "radio_btn":
                    return "<input type='".($customtype?:"radio")."' name='$name' class='$class''" . ($required?:"required") . ">";
                case "select_menu":
                    return "<input type='".($customtype?:"radio")."' name='$name' class='$class''" . ($required?:"required") . ">";
                case "textarea":
                    return "<input type='".($customtype?:"radio")."' name='$name' class='$class''" . ($required?:"required") . ">";
            }
        }
    
    
    }

// QuestionOption model

    class QuestionOption extends Model
    {
        protected $fillable = [ 'question_id', 'value' ];
    
        public function question() {
            return $this->belongsTo('App\Question');
        }
    }

adamjhn started a new conversation Show Questions With The Appropriate Type • 2 days ago

I have a form for a user create custom questions. For that the user needs to introduce the question and also the type of field (text, long text, checkbox, select menu, radio button).

If the user selects one of this types: checkbox, select menu or radio button the div "#availableOptions" appears for the user to write the options for the questions of that type using jQuery.

This is working fine. My doubt is then in the registration.blade.php view how to show the custom questions based on he correct type (checkbox, text, radio button, ec). For now the custom questions are appearing correctly but all custom questions appear with input type text. Do you know how to show the correct type based on the type that is stored in the questions table "type" column?

Form for the user create the custom question:

    <form method="post" class="clearfix" action="{{route('questions.store', ['conference_id' => $conference->id])}}" enctype="multipart/form-data">
        {{csrf_field()}}
        <div class="form-group">
            <label for="question">Question</label>
            <input type="text" class="form-control" name="question" id="question">
        </div>
        <div class="form-group">
            <label for="type">Type of field</label>
            <select class="form-control" name="type" id="customQuestionType">
                <option value="text">Text</option>
                <option value="long_text">Long Text</option>
                <option value="checkbox">Checkbox</option>
                <option  value="radio_btn">Radio Button</option>
                <option  value="select_menu">Select menu</option>
            </select>
        </div>
    
        <div>
            <input type="submit" class="btn btn-primary" value="Store"/>
        </div>
    </form>
    
    <div class="form-group" id="availableOptions">
        <label for="inputName">Available options</label>
        <div class="option  d-flex justify-content-between">
            <input type="text" class="form-control col-md-8">
            <input type="button" class="removeOption btn btn-outline-primary col-md-3" value="Remove option"/>
        </div>
        <div class="option mt-3 d-flex justify-content-between">
            <input type="text" class="form-control col-md-8">
            <input type="button" class="removeOption btn btn-outline-primary col-md-3" value="Remove option"/>
        </div>
    </div>

So the user can write a question, for example, "Receive newsletter?", select the type checkbox, introduce in the "#availableOptions" div the options, for example, for the option 1 the value "opt1", and for the option 2 the value "opt2".

And the question, type, conference_id is introduced in the questions table and the question_id and value of each option ("opt1" and "opt2") are stored in the question_options table. For this there is the QuestionController store() method:

    public function store(Request $request, $id){
        $this->validate($request, [
            'question' => 'required|max:255|string',
            'type' => 'required|max:255|string',
        ]);
        $conference = Conference::find($id);
        $question = Question::create([
            'conference_id' => $conference->id,
            'question' => $request->question,
            'type' => $request->type,
        ]);
    
    
        if(in_array($request->type, Question::$typeHasOptions)){
            foreach($request->input('questionOptions') as $questionOption) {
                QuestionOption::create([
                    'question_id' => $question->id,
                    'value' => $questionOption
                ]);
            }
        }
        Session::flash('success', 'Question created with success.');
        return redirect()->back();
    }

The questions appear on the view like:

@if ($allParticipants == 0)
    @foreach($selectedType['questions'] as $customQuestion)
        <div class="form-group">
            <label for="participant_question">{{$customQuestion->question}}</label>
            <input type="text"
                   @if($customQuestion->pivot->required == "1") required @endif
                   class="form-control" name="participant_question[]">
            <input type="hidden" name="participant_question_required[]"
                   value="{{ $customQuestion->pivot->required }}">
            <input type="hidden" value="{{ $customQuestion->id }}" name="participant_question_id[]"/>
        </div>
    @endforeach
@endif

Models:

// Question model
class Question extends Model
{
    protected $fillable = [
        'question', 'type', 'event_id',
    ];

    public static $typeHasOptions = [
        'radio_btn',
        'select_menu',
        'checkbox'
    ];

    public function ticket_types(){
        return $this->belongsToMany('App\TicketType', 'ticket_type_questions')
            ->withPivot('required');
    }

    public function options() {
        return $this->hasMany('App\QuestionOption');
    }


    public function hasOptions() {
        return in_array($this->type, self::$typeHasOptions);
    }

}

// QuestionOption model


class QuestionOption extends Model
{
    protected $fillable = [ 'question_id', 'value' ];

    public function question() {
        return $this->belongsTo('App\Question');
    }
}

23rd May, 2018

adamjhn started a new conversation Get Conferences Of All Country When User Clicks In "Country" • 3 days ago

I have a modal that has some cities. If the user clicks in a city then in the #conferences div it appears the conferences that have in the column "city" that clicked city. This is working fine.

My doubt is how to, if the user clicks in Country, instead of a city, how to get all conferences, independently of the city because if the user clicks in Country the results can be of any city.

Do you know how to achieve that?

With value attribute like "Country" when "Country" is clicked in the console appears: " {message: "", "exception: "Symfony\Component\HttpKernel\Exception\NotFoundHttpException",…}" in file "/Illuminate/Routing/RouteCollection.php".

ConferenceController method to get the conferences of the clicked city:

      public function getConferencesOfCity($slug)
        {
    
            $conferences = Conference::whereCity($slug)->get();
          
    
            return response()->json($conferences);
        }

Modal where the city links appear:

    <div class="modal-body">
        <div class="container">
            <ul class="modal-list row">
                <li class="col-lg-4 col-md-6 col-sm-12">
                    <a  class=""  name="" id="" value="">Country</a>
                </li>
                @foreach($cities as $city)
                    <li class="col-lg-4 col-md-6 col-sm-12">
                        <a  class=""  name="city" id="{{$city}}">{{$city}}</a>
                    </li>
                @endforeach
            </ul>
        </div>
    </div>

Route:

    Route::get('conferences/where/city/{slug}','[email protected]')->name('city.conferences');

jQuery ajax request:

    $("a[name='city']").on('click', function(){
    
        $('#showCities').html($(this).text());
        var city = $(this).attr("id");
    
        $.ajax({
            url: '{{ route('city.conferences',null) }}/' + city,
            type: 'GET',
            success:function(result){
                console.log(result)
    
                $('#conferences').empty();
                var newConferences='';
                var placeholder = "{{route('conferences.show', ['id' => '1', 'slug' => 'demo-slug'])}}";
                $.each(result, function(index, conference) {
                    $('#modal2').modal('hide');
                    var url = placeholder.replace(1, conference.id).replace('demo-slug', conference.slug);
    
                    newConferences += '<div class="col-12 col-sm-6 col-lg-4 col-xl-3 mb-4">\n' +
                        '                                <h5 class="card-title">'+conference.name+'</h5>\n' +
                        '                                <p class="card-text font-size-sm">'+conference.city+'</p>\n' +
                    '                    </div>\n';
                });
                $('#conferences').html(newConferences);
            },
            error: function(error) {
                console.log(error.status)
            }
        });
    });

22nd May, 2018

adamjhn left a reply on Do You Know Why Distinct() Is Not Working Properly? • 4 days ago

With

"$cities = Conference::where('city', 'LIKE', '%'.$search.'%')->groupBy('city')->get();"

it appears


"SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'project.conferences.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by (SQL: select * from conferences where city LIKE %new% group by city)".

adamjhn started a new conversation Do You Know How Distinct() Is Not Working Properly? • 4 days ago

I have an input search using autocomplete plugin that shows the conference names and cities where the conferences will happen. When the user types 1 word it appears the results in the autocomplete.

But there is an issue, for example, if there are in the conferences table two conferences that have the city column equal, example "Newcastle" in the autocomplete input appears "Newcastle" twice. But it should appear only one time. It seems that the distinct() in " $cities = Conference::where('city', 'LIKE', '%'.$search.'%')->distinct()->get();" is not working properly.

AutoCompleteController:

class AutocompleteController extends Controller
{
    public function index(){
    return view('autocomplete.index');
    }

    public function search(Request $request){
        $search = $request->term;
        $conferences = Conference::where('name', 'LIKE', '%'.$search.'%')->distinct()->get();

        $cities = Conference::where('city', 'LIKE', '%'.$search.'%')->get();

        //dd($cities); 
        $data= [];
        foreach ($conferences as $key => $value){
            $data[] = ['category'=> 'Conferences', 'value' => $value->name, 'url' => 'conference/'.$value->id.'/'.$value->slug];
        }

        foreach ($cities as $key => $value){
            $data[] = ['category'=> 'Cities', 'value' => $value->city, 'url' => 'conferences/where/city/'.$value->city];
        }
        return response($data);
    }
}

Autocomplete Jquery:

$.widget( "custom.catcomplete", $.ui.autocomplete, {
_create: function() {
    this._super();
    this.widget().menu( "option", "items", "> :not(.ui-autocomplete-category)" );
    },
    _renderMenu: function( ul, items ) {
    var that = this,
    currentCategory = "";
    $.each( items, function( index, item ) {
        var li;
        if ( item.category != currentCategory ) {
            ul.append( "<li class='ui-autocomplete-category bg bg-light-gray2 h6 font-weight-bold text-heading-blue'>"
            + item.category + "</li>" );
            currentCategory = item.category;
        }
        li = that._renderItemData( ul, item );
        if ( item.category ) {
        li.attr( "aria-label", item.category + " : " + item.label );
        }
    });
    }
});

$("#search").catcomplete({
    source: "{{ URL::to('autocomplete-search') }}",
    select: function(event, ui) {
    window.location.href = ui.item.url;
}

When "New" is typed dd($cities) shows:

Collection {#274
#items: array:2 [
0 => Conference {#275
#fillable: array:18 [
0 => "name"
5 => "city"
...
]
#dates: array:2 [
0 => "start_date"
1 => "end_date"
]
#appends: array:1 [
0 => "price_range"
]
#connection: "mysql"
#table: null
#primaryKey: "id"
#keyType: "int"
+incrementing: true
#with: []
#withCount: []
#perPage: 15
+exists: true
+wasRecentlyCreated: false
#attributes: array:23 [
"id" => 1
"name" => "conf1"
"city" => "Newcastle"
]
#original: array:23 [
"id" => 1
"name" => "conf1"
"city" => "Newcastle"
]
#changes: []
#casts: []
#dateFormat: null
#dispatchesEvents: []
#observables: []
#relations: []
#touches: []
+timestamps: true
#hidden: []
#visible: []
#guarded: array:1 [
0 => "*"
]
}
1 => Conference {#276
#fillable: array:18 [
0 => "name"
5 => "city"
...
]
#dates: array:2 [
0 => "start_date"
1 => "end_date"
]
#appends: array:1 [
0 => "price_range"
]
#connection: "mysql"
#table: null
#primaryKey: "id"
#keyType: "int"
+incrementing: true
#with: []
#withCount: []
#perPage: 15
+exists: true
+wasRecentlyCreated: false
#attributes: array:23 [
"id" => 2
"name" => "conf2"
"city" => "Newcastle"
...
]
#original: array:23 [
"id" => 2
"name" => "conf2"
"city" => "Newcastle"
...
]
#changes: []
#casts: []
#dateFormat: null
#dispatchesEvents: []
#observables: []
#relations: []
#touches: []
+timestamps: true
#hidden: []
#visible: []
#guarded: array:1 [
0 => "*"
]
}
]
}

adamjhn left a reply on Why The Results Are Appearing On A Different Page And Not In The Same Page? • 4 days ago

It seems that it works with " ui.item.url" instead of "url".

adamjhn left a reply on Why The Results Are Appearing On A Different Page And Not In The Same Page? • 4 days ago

Thanks, it worked. There is only one issue.

In the newConferences I need to have a url variable to use like:

...
<div class="card-footer d-flex justify-content-between align-items-center">\n' +
'                                 <a href="' + url + '" class="btn btn-primary text-white">More</a>' +
' <span class="font-weight-bold font-size-sm text-heading-blue"> Free</span>\n'+
'                           </div>\n' +
...

So in the ajax post request I created that variable like:

...
 $.ajax({
        url: '{{ route('city.conferences',null) }}/' + city,
        type: 'GET',
        success:function(result){
            console.log(result)
...

But in the autocomplete like below is not working, it appears "Uncaught SyntaxError: Unexpected token var", like:

...
$.get(ui.item.url, function(result) {
    url: '{{ route('city.conferences',null) }}/' + city,
    var newConferences = '';
...

adamjhn started a new conversation Why The Results Are Appearing On A Different Page And Not In The Same Page? • 4 days ago

When the user writes for example "Ne" in the autocomplete appears the city "Newcastle". When the user clicks in "Newcastle" in the autocomplete input the user is redirected to "proj.test/conferences/where/city/Newcastle"; and the results, in this case there is only one, appears in that page like: [ { "id": 1, "name": "conference test", "city": "Newcastle", ...}].

But the results should appear in the #conferences div, not in another page.

Do you know where is the issue?

AutoCompleteController:

class AutocompleteController extends Controller
{
    public function index(){
    return view('autocomplete.index');
    }

    public function search(Request $request){
        $search = $request->term;
        $conferences = Conference::where('name', 'LIKE', '%'.$search.'%')->get();

        $cities = Conference::where('city', 'LIKE', '%'.$search.'%')->get();

        $data= [];
        foreach ($conferences as $key => $value){
            $data[] = ['category'=> 'Conferences', 'value' => $value->name, 'url' => 'conference/'.$value->id.'/'.$value->slug];
        }

        foreach ($cities as $key => $value){
            $data[] = ['category'=> 'Cities', 'value' => $value->city, 'url' => 'conferences/where/city/'.$value->city];
        }
        return response($data);
    }
}

Autocomplete jQuery:

$.widget( "custom.catcomplete", $.ui.autocomplete, {
_create: function() {
    this._super();
    this.widget().menu( "option", "items", "> :not(.ui-autocomplete-category)" );
    },
    _renderMenu: function( ul, items ) {
    var that = this,
    currentCategory = "";
    $.each( items, function( index, item ) {
        var li;
        if ( item.category != currentCategory ) {
            ul.append( "<li class='ui-autocomplete-category bg bg-light-gray2 h6 font-weight-bold text-heading-blue'>"
            + item.category + "</li>" );
            currentCategory = item.category;
        }
        li = that._renderItemData( ul, item );
        if ( item.category ) {
        li.attr( "aria-label", item.category + " : " + item.label );
        }
    });
    }
});

$("#search").catcomplete({
    source: "{{ URL::to('autocomplete-search') }}",
    select: function(event, ui) {
    window.location.href = ui.item.url;
}

AutoCompleteController:

class AutocompleteController extends Controller { public function index(){ return view('autocomplete.index'); }

public function search(Request $request){
    $search = $request->term;
    $conferences = Conference::where('name', 'LIKE', '%'.$search.'%')->get();

    $cities = Conference::where('city', 'LIKE', '%'.$search.'%')->get();

    $data= [];
    foreach ($conferences as $key => $value){
        $data[] = ['category'=> 'Conferences', 'value' => $value->name, 'url' => 'conference/'.$value->id.'/'.$value->slug];
    }

    foreach ($cities as $key => $value){
        $data[] = ['category'=> 'Cities', 'value' => $value->city, 'url' => 'conferences/where/city/'.$value->city];
    }
    return response($data);
}

}



I have a link "Show cities" when is clicked it appears a modal with some cities:

Show cities


The div #conferences" that show the conferences, the results:

@foreach(conferences as $conference)
{{$conference->name}}

{{$conference->place}}, {{$conference->city}}

@endforeach ```

jQuery ajax request that is already working when a user clicks in a city that appears in a modal

$("a[name='city']").on('click', function(){

    $('#showCities').html($(this).text()+' <i class="fa fa-caret-down" aria-hidden="true"></i>');

        var city = $(this).attr("id");

        $.ajax({

        url: '{{ route('city.conferences',null) }}/' + city,
        type: 'GET',
        success:function(result){
        console.log(result)

        $('#conferences').empty();
        var newConferences='';
        var placeholder = "{{route('conferences.show', ['id' => '1', 'slug' => 'demo-slug'])}}";
        $.each(result, function(index, conference) {
        $('#modal2').modal('hide');
        var url = placeholder.replace(1, conference.id).replace('demo-slug', conference.slug);

        newConferences += '<div class="col-12 col-sm-6 col-lg-4 col-xl-3 mb-4">\n' +
            '    <div class="card-body">\n' +
                '      <h5 class="card-title h6 font-weight-bold text-heading-blue">'+conference.name+'</h5>\n' +
                '      <p class="card-text font-size-sm"><i class="fa fa-map-marker" aria-hidden="true"></i> '+conference.city+'</p>\n' +
                '     </div>\n' +
            '   </div>\n';
        });
        $('#conferences').html(newConferences);

        },
        error: function(error) {

        console.log(error.status)
        }
    });
});

18th May, 2018

adamjhn left a reply on Get All Conferences That Will Happen In A Specific City • 1 week ago

Thanks Im using jquery ui with:

    $("#search").autocomplete({
       source: "{{ URL::to('autocomplete-search') }}",
       minLength: 2,
       select:function(key, value)
       {
           console.log(value);
       }
    });

Im already getting the conference names in the autocomplete with:

            $conferences = Conference::where('name', 'LIKE', '%'.$search.'%')->get();

´´´

And with the conference slug is possible to return the user to the conference details page.

But in the case of the cities do you know how to get the names of the cities in the AutoCompleteController to show the cities in the autocomplete so is possible the user to click in the city?

adamjhn left a reply on Get All Conferences That Will Happen In A Specific City • 1 week ago

I create a image to explain better: http://ibb.co/b936gT

For example if the user introduce "Ne" in the input text it appears the conferences that have the name like "Ne" and also cities like "Ne"

If a conference is clicked the user go to the conference details page. If the user clicks in the city Newcastle the user goes to the search page and are listed the conferenes in city "Newcastle".

adamjhn left a reply on Get All Conferences That Will Happen In A Specific City • 1 week ago

Thanks, but like that dont work as it should. Like that when the user writes in the input text for example "Ne" it appears the title of the conference that has the name like "Ne" or city column like "Ne".

But what I want to show in the autocomplete input the city, for example "Newcastle", and then the user click in "Newcastle" and then show the results, the conferences where the column "city" is Newcastle in a div.

adamjhn started a new conversation Get All Conferences That Will Happen In A Specific City • 1 week ago

I have a context where there is a conferences table that stores the conferences. The conference table has a column "name" and also a column city".

I have an input type text and the user should be able to search for conference names but also for conferences that will happen in a specific city.

For example, if there are 4 conferences in the database:

Conferences table

    id | name | city | ...

     1 |  abcd  | Newcastle
     2 |  efgh  | Newcastle
     3 |  ablp  | Bristol
     4 |  nopq  | Glasgow

So the user in the input can want to do a search for conferences. For example if he writes in the input text "ab" it should appaer in the autocomplete "abcd" and "ablp" and then the user clicks in "abcd" or "ablp" and the code should get that specific conference. This is working fine.

My doubt is to allow also this context: The user in the input can want to do a search for cities. For example if he writes in the input text "Gl" it should appear in the autocomplete "Glasgow" and then the user clicks in Glasgow and the code should get all conferences that will happen in Glasgow city.

Do you know how this can be achieved?

AutoCompleteController

    class AutocompleteController extends Controller
    {
    
        public function search(Request $request){
            $search = $request->term;
            $conferences = Conference::where('name', 'LIKE', '%'.$search.'%')->get();
    
            $data= [];
            foreach ($conferences as $key => $value){
                $data[] = ['id'=> $value->id, 'value' => $value->name . " " . $value->name];
            }
            return response($data);
        }
    }

Route to above method:

    Route::get('/autocomplete-search', '[email protected]');

jQuery:

    $("#search").autocomplete({
       source: "{{ URL::to('autocomplete-search') }}",
       minLength: 2,
       select:function(key, value)
       {
           console.log(value);
       }
    });

Search input:


    <div class="col col-md-6">
        <h4 class="text-white  text-center font-weight-bold">Search</h4>
        <form class="main-search">
            <input type="text" id="search" class="autocomplete dropdown-toggle" placeholder="Conference, Citiy, Category">
        </form>
    </div>

17th May, 2018

adamjhn started a new conversation How To Get The Answers To Custom Questions Of Each Participant? • 1 week ago

I have a view to show info about all registrations in a specific conference, the name and surname of the user that did the registration, etc. Then I also have a link "Details". When "Details" is clicked it appears a modal with the registration details:

  • the user that did the registration
  • the name and surname of each registered participant(s) in that clicked registration

My doubt is how to show also besides this info above (the user that did the registration and the name and surname of each participant) to show the answers to custom questions if they exist. That is, a ticket type may have custom questions associated to it. For example, the user John is doing a registration in the conference "conference test" and for exmaple this conference has two ticket types associated: tt1 and tt2. And both ticket types (tt1 and tt2) have the custom question "Whats your phone?" associated to them. So in the "conference test" registration form this questions will appaer for each ticket and John need to answer to the question "Whats your phone?" for each ticket.

So I also want to show here the answers to the custom questions, but Im not understanding how. Do you know what is necessary to get the answers? Is necessary a 1 to many relationship between Participant and Answer?

@foreach($event->registrations as $registration)
    <tr>
        <td>{{$registration->customer->name}} {{$registration->customer->surname}}</td>
        <td>...</td>
        <td>
            <a class="btn btn-primary showDetails" data-regid="{{$registration->id}}">Details</a>
        </td>
    </tr>

    <div class="modal fade" id="registrationDetails-{{ $registration->id }}" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-sm">
            <div class="modal-content">
                <div class="modal-body">
                    <dl>
                        <dt>Name</dt>
                        <dd>{{ $registration->customer->name }}</dd>
                        <dt>Email</dt>
                        <dd>{{ $registration->customer->email }}</dd>
                    </dl>

                  @foreach ($registration->participants as $participant)
                      <dl>
                          <dt>Name</dt>
                          <dd>{{ $participant->name }}</dd>
                          <dt>Surname</dt>
                          <dd>{{ $participant->surname }}</dd>
                          <dt>Ticket Type</dt>
                          <dd>{{ $participant->registration_type->name }}</dd>
                      </dl>
                  @endforeach
        </div>
    </div>
@endforeach

Laravel Models:

class Conference extends Model
{ 
    // A conference has one creator
    public function creator(){
        return $this->belongsTo('App\User', 'user_id');
    }
    public function ticketTypes(){
        return $this->hasMany('App\TicketType', 'conference_id');
    }
    public function registrations(){
        return $this->hasMany('App\Registration', 'conference_id');
    }
}

// User model
class User extends Authenticatable
{
    public function congresses(){
        return $this->hasMany('App\Conference', 'user_id');
    }

    // A user can register in many conferences
    public function registrations(){
        return $this->hasMany('App\Registration','main_participant_id');
    }
}

// Registration model
class Registration extends Model
{
    // a registration has one user that do the registration
    public function customer(){
        return $this->belongsTo('App\User');
    }

    // a registration can have many participants
    public function participants(){
        return $this->hasMany('App\Participant');
    }

    public function conference(){
        return $this->belongsTo('App\Conference');
    }
}

// Participant Model
class Participant extends Model
{
    // a participant belongs to a registration
    public function registration(){
        return $this->belongsTo('App\Registration');
    }
     public function ticket_type(){
        return $this->belongsTo('App\TicketType');
    }
}

// Ticket Type model
class TicketType extends Model
{
    public function conference(){
        return $this->belongsTo('App\Conference');
    }

    public function questions(){
        return $this->belongsToMany('App\Question', 'ticket_type_questions')->withPivot(['required']);;
    }

     // a registration can have many participants
    public function participants(){
        return $this->hasMany('App\Participant');
    }
}

// Question model
class Question extends Model
{
    public function ticket_type(){
        return $this->belongsToMany('App\TicketType', 'ticket_type_questions')
            ->withPivot('required');
    }
}

// Answer model
class Answer extends Model
{
    public function question(){
        return $this->belongsTo('Question');
    }
    public function participant(){
        return $this->belongsTo('Participant');
    }
}

// TicketTypeQuestion model
class TicketTypeQuestion extends Model
{
}

16th May, 2018

adamjhn left a reply on How To Get The Id Of The Registrations That Are Dynamic In JQuery? • 1 week ago

Thanks!

Something like this?

$(function() {

            $("#showDetails").on("click", function () {

                let regID = $(this).data('regid');

                $('#registrationDetails'+regID).modal('show');

            });

        });

Like that when the Details link is clicked the modal dont open. Do you know why?

adamjhn started a new conversation How To Get The Id Of The Registrations That Are Dynamic In The JQuery? • 1 week ago

I have this code below to show in a table info about registrations in a specific congress:

@foreach($conference->registrations as $registration)
    <tr>
        <td>{{$registration->customer->name}} {{$registration->customer->surname}}</td>
        <td>{{ $registration->participants->count() }}</td>
        ...
        <td>
        <a class="btn btn-primary" id="showDetails">Details</a>
        </td>
</tr>
@endforeach

But then with the "Details" link is to open a modal that it is in this page so is possible to show the details of that specific registration (in that ).

But since each registration needs to have its own modal to show its specific details I put the modal inside the foreach and add registration id like "id="registrationDetails-{{ $registration->id }}". But its not working properly when the "Details" link is clicked in any row the modal dont appears.

The issue shoudl be because then is necessary to in jQuery get the correct id, which is dynamic because it has the id of each registration: "id="registrationDetails-{{ $registration->id }}".

Do you know how get the id in the dynamic jQuery?

The modal html:

<div class="modal fade"  id="registrationDetails-{{ $registration->id }}" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        <div class="container">
          <div class="row">

            <!-- User that did the registration -->
            <dl>
              <dt>Name</dt>
              <dd>{{ $registration->customer->name }}</dd>
              <dt>Email</dt>
              <dd>{{ $registration->customer->email }}</dd>
            </dl>

            @foreach ($registration->participants as $participant)

            <!-- Participant N -->
            <dl>
              <dt>Name</dt>
              <dd>{{ $participant->name }}</dd>
              <dt>Surname</dt>
              <dd>{{ $participant->surname }}</dd>
              <dt>Ticket Type</dt>
              <dd>{{ $participant->ticket_type->name }}</dd>
            </dl>

            @endforeach
          </div>

        </div>
      </div>
      <div class="modal-footer">
        <button type="button" id="close_login_modal" class="btn btn-primary" data-dismiss="modal">Close</button>
      </div>
    </div>
  </div>
</div>

jQuery:

@section('scripts')

<script type="text/javascript" src="{{url('js/jquery-ui.js')}}"></script>

<script type="text/javascript">
$(function() {
    $("#showDetails").on("click", function () {
    $('#registrationDetails').modal('show');
    });
});
</script>
@endsection

adamjhn left a reply on Modal Is Not Appearing On Option Selection • 1 week ago

Thanks, I delete the select2 code from the app.js file. But the error still appears on the console:

Uncaught TypeError: $(...).select2 is not a function
    at HTMLDocument.<anonymous> (app.js:82)
    at j (jquery.min.js:2)
    at k (jquery.min.js:2)

And it appears that is in the line 82 and if that link is clicked it appears the app.js in the console and the select2 code appears there that select2 code, but in the project file "app.js" I remove that code. I clear the cache but same isssue. Do you know where can be the issue?

adamjhn left a reply on Modal Is Not Appearing On Option Selection • 1 week ago

The issue should be because of that, the app.js is included in all pages and the app.js have that select2 code but some pages are not including the select2. Do you know how to correct the issue?

adamjhn left a reply on Modal Is Not Appearing On Option Selection • 1 week ago

It seems that this error appears in all pages that dont use the select2 plugin.

adamjhn left a reply on Modal Is Not Appearing On Option Selection • 1 week ago

Yes this error still appears:

Uncaught TypeError: $(...).select2 is not a function
    at HTMLDocument.<anonymous> (app.js:82)
    at j (jquery.min.js:2)
    at k (jquery.min.js:2)

adamjhn left a reply on Modal Is Not Appearing On Option Selection • 1 week ago

In this page where I have this showDetails jQuery in the source code the scripts are imported in the bottom of the file like:

<!-- html code -->

<script src="//ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script>
<script type="text/javascript" src="http://proj.test/js/bootstrap.js"></script>
<script type="text/javascript" src="http://proj.test/js/app.js"></script>
<script type="text/javascript" src="http://proj.test/js/toastr.min.js"></script>
<script>
        </script>
    <script type="text/javascript" src="http://proj.test/js/jquery-ui.js"></script>

    <script type="text/javascript">
        $(function() {
            alert("test");
            $("#showDetails").on("change", function () {
                alert("tst");
                var showDetails = $(this).val();
                alert(showDetails);
                if (showDetails === 'showDetails') {
                    $('#details').modal('show');
                }
            });
        });

        </script>

</body>

</html>

adamjhn left a reply on Modal Is Not Appearing On Option Selection • 1 week ago

That select2 code is just used in two pages so I just have in that pages the

@section('scripts')
    <script src="{{ asset('js/select2.min.js') }}"></script>
...
@endsection

In the other pages I dont import the select2 plugin.

adamjhn left a reply on Modal Is Not Appearing On Option Selection • 1 week ago

Thanks, it was an error closing "$(function() {...". The other error select2 still appears I dont know why. In line 82 the code is:

 $('#tag_list').select2({
        placeholder: '',
        dropdownAutoWidth: 'true',
        width: '100%'
    });

adamjhn left a reply on Modal Is Not Appearing On Option Selection • 1 week ago

Yes, this alert("test") is also not appearing:

@section('scripts')

    <script type="text/javascript" src="{{url('js/jquery-ui.js')}}"></script>

    <script type="text/javascript">
        $(function() {
            alert("test");
            ...
            })

        }
@endsection

In the console appears 1 error I dont know why:

jquery.min.js:2 Uncaught TypeError: $(...).select2 is not a function
    at HTMLDocument.<anonymous> (app.js:82)
    at j (jquery.min.js:2)
    at k (jquery.min.js:2)

I dont know if can be because of that error.

adamjhn left a reply on Modal Is Not Appearing On Option Selection • 1 week ago

Thanks but also dont appaers, even the alert is not appearing in:

$("#showDetails").on("change", function () {
                var showDetails = $(this).val();
                alert(showDetails);

adamjhn started a new conversation Modal Is Not Appearing On Option Selection • 1 week ago

I have this modal:

    <div class="modal fade" id="details" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
        test
    </div>

That I want to show when the option "shows details is selected"

<select id="exampleFormControlSelect1">
    <option id="showDetails">Show details</option>
    <option>Notify</option>
</select>

So I have this jquery below, but the modal dont appears. Do you know why?

 $(function() {
            $('#showDetails').change(function(){
                $('#details').modal('show');
            })

        }

adamjhn left a reply on Do You Know What Is Necessary To Have A Search Autocomplete Input Text With Laravel? • 1 week ago

Thanks but like this:

    return response($conferences);

Now if the user writes "co" in the input it appears two lines but wihout any next. But in the network tab appears:

[{id: 1, name: "Conf test", description: "", start_date: "2018-03-08 06:30:00",…}]
0
:
{id: 1, name: "Conf test", description: "", start_date: "2018-03-08 06:30:00",…}

adamjhn started a new conversation Do You Know Why Is Appearing This Error "View [app] Not Found. "? • 1 week ago

Do you know why is appearing this error "View [app] not found. "?

I have this route:

Route::get('/search', [
    'uses' => '[email protected]',
    'as'   => 'search.index'
]);

And in the controller:

class SearchController extends Controller
{
    public function index(){

        return view('search');
    }
}

And search.blade.php is in the views folder.

adamjhn left a reply on Do You Know What Is Necessary To Have A Search Autocomplete Input Text With Laravel? • 1 week ago

And can you explain better that part iabout to secure with checks?

adamjhn left a reply on Do You Know What Is Necessary To Have A Search Autocomplete Input Text With Laravel? • 1 week ago

Thanks I have the code below but its not working properly. There are two issues:

  • first when the user writes for example "co" in the input and there is a conference with the name "conf" it appears in the autocomplete input "conf conf" instead of just "conf".
  • and for the cities is not working, if there is a city "Newcastle" and the user writes "Ne" not result appears.

Do you know why?

class AutocompleteController extends Controller
{

    public function search(Request $request){
        $search = $request->term;
        $conferences = Conference::where('name', 'LIKE', '%'.$search.'%')
            ->orWhere('city', 'LIKE', '%'.$search.'%')
            ->get();

        $data= [];
        foreach ($conferences as $key => $value){
            $data[] = ['id'=> $value->id, 'value' => $value->name . " " . $value->name];
        }
        return response($data);
    }
}

The route:

Route::get('/autocomplete-search', '[email protected]');

jQuery:

$("#search").autocomplete({
   source: "{{ URL::to('autocomplete-search') }}",
   minLength: 2,
   select:function(key, value)
   {
       console.log(value);
   }
});

adamjhn started a new conversation Do You Know What Is Necessary To Have A Search Autocomplete Input Text With Laravel? • 1 week ago

I have a context where there is a conferences table that stores the confeerences. The conferene table has a column "city". Also there is a many to many relationship between conferences and categories. A conference can have many categories and one category can belong to many conferences.

Do you know what is necessary to have a search fucntionality, a input text where the user can type for example 3 letters like "new" and it appears in the input text the results of categories with name like "new", for conferences with name like "new" and for conferences with city like "new"? There is some jquery plugins like autocomplete for this, but in terms of laravel do you know which is necessary?

adamjhn left a reply on Why Are Not Appearing All Conferences That Belong To The Clicked Category? • 1 week ago

Thanks but same error:

"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'categories.conference_id' in 'where clause' (SQL: select * from conferences where exists (select * from categories where conferences.id = categories.conference_id and category_conference.id = 2))".

15th May, 2018

adamjhn left a reply on Why Are Not Appearing All Conferences That Belong To The Clicked Category? • 1 week ago

Like this:

    public function WhereHasCategory($id, Request $request)
    {
        $conferences = Conference::whereHas('categories', function ($categories) use ($id) {
            $categories->where($id, $request->id);
        })->get();
        
        return response()->json($conferences);
    }

It shows an error in "where($id, $request->id);" undefined variable $request.

adamjhn left a reply on Why Are Not Appearing All Conferences That Belong To The Clicked Category? • 1 week ago

In the WhereHasCategory() method?

adamjhn left a reply on Why Are Not Appearing All Conferences That Belong To The Clicked Category? • 1 week ago

Thanks but still appears:

"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'categories.conference_id' in 'where clause' (SQL: select * from conferences where exists (select * from categories where conferences.id = categories.conference_id and category_conference.id = 2))".

The "return $request->id;" shows "2" in the network tab.

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.