boldstar

Experience

520

0 Best Reply Awards

  • Member Since 2 Weeks Ago
  • 0 Lessons Completed
  • 0 Favorites

17th September, 2018

boldstar left a reply on Input Type For Select Not Working • 2 days ago

@Snapey No, it still does not automatically select it. I figured out how to submit the select option data as integer instead of string but the user at this point still has to manually select the client.

I guess the only difference at this point is that they do not have to input it manually, they only select it.

boldstar left a reply on Input Type For Select Not Working • 2 days ago

@Snapey, yes it is able to grab the client id from the router link

 <router-link v-bind:to="'/add-engagement/' +client.id" >Engagement</router-link>

and in my add engagement component I am using a getter so it has the information of the client the add engagement is for. So the v-bind:value="client.id" is coming from my getter.

computed: {
    ...mapGetters(
        [
          'client',
        ]
      )
  },

The only issue I'm having now is it will drop the id of the client if I refresh the page which is not ideal..

16th September, 2018

boldstar left a reply on Input Type For Select Not Working • 3 days ago

@Snapey, my issue was the select option would was submitting the data as a string instead of a number so I still use the select option but

instead of this

v-model="engagement.client_id"

I used this

v-model.number="engagement.client_id"

My other issue was that the v-bind:value I had set was incorrect.

v-bind:value="client.id"

instead of

v-bind:value="engagement.client_id"

My final result looks like this

<select class="form-control mb-3" id="client_id" v-model.number="engagement.client_id">
     <option  v-bind:value="client.id">{{ client.last_name }}</option>
</select>

boldstar left a reply on Input Type For Select Not Working • 3 days ago

@Snapey, Well I want the form to already be populated with the client_id information so that the user does not have to input it manually.

So I was using the select option because it was the only one that I have found where it will put the information into the form input, but instead of looping through a list of data options I just have the client_id as the option...

Unless there is another input type that I could use to automatically place the information into the form...

15th September, 2018

boldstar started a new conversation Input Type For Select Not Working • 4 days ago

Trying to add a getters state into my form before the user submits data but at this point I am only able to input the client_id manually.

This works

<input class="form-control mb-3" type="number" id="client_id" v-model="engagement.client_id">

This does not work, although I am able to put the data into the form for the user...

<select class="form-control mb-3" id="client_id" type="number" v-model.number="engagement.client_id">
              <option  :value="engagement.client_id">{{ client.id }}</option>
            </select>

This is the vue component for the form

<template>
  <div class="page-wrapper mt-1">
    <div class="add-engagement container">
      <div class="card-body bg-light border-primary mb-2">
        <h4 class="text-left text-primary m-0"><i class="mr-3 far fa-folder-open"></i>New Engagement</h4>
      </div>
        <form @submit.prevent="addEngagement" class="d-flex-column justify-content-center">
          <div class="form-group">
            <select class="form-control mb-3" id="client_id" type="number" v-model.number="engagement.client_id">
              <option  :value="engagement.client_id">{{ client.id }}</option>
            </select>
            <select class="form-control mb-3" id="type" v-model="engagement.return_type">
              <option v-for="type in types" :key="type.id" :value="type">{{ type }}</option>
            </select>
            <input type="text" class="form-control mb-3" placeholder="Year" v-model="engagement.year">
            <input type="text" class="form-control mb-3" placeholder="Assign To" v-model="engagement.assigned_to">
            <input type="text" class="form-control mb-3" placeholder="Status" v-model="engagement.status">

            <button type="submit" class="btn btn-lg btn-primary d-flex justify-content-start">Create</button>
          </div>
        </form>
      </div>  
  </div>
</template>

<script>
import { mapGetters } from 'vuex'

export default {
  name: 'add-engagement',
  data() {
    return {
      engagement: {
        client_id: null,
        return_type: null,
        year: '',
        assigned_to: '',
        status: '',
      },
      types: [ 
        'Choose Return Type...', 
        '1040', 
        '1120',
      ],
    }
  },
  computed: {
    ...mapGetters(
      [
        'client',
      ]
      )
  },
   methods: {
    addEngagement(e) {
      if(!this.engagement.return_type || !this.engagement.year ){
        return
      } else {
        this.$store.dispatch('addEngagement', {
          id: this.idForEngagement,
          client_id: this.engagement.client_id,
          return_type: this.engagement.return_type,
          year: this.engagement.year,
          assigned_to: this.engagement.assigned_to,
          status: this.engagement.status,
        })
        e.preventDefault();
      }
      e.preventDefault();
      this.engagement = "" 
      this.idForEngagement++
      this.$router.push('/engagements')
    },
  },
  created: function(){
    this.engagement.client_id = this.$store.getters.client.id
  },
  created: function() {
    this.engagement.return_type = this.types[0]
  },
}
</script>

<style lang="scss" scoped>

</style>

Using the select I am able to render the client data into the form but on submit I get a 422 unprocessible alarm which makes me think it is because the input type is not being set to a number for the select dropdown.

Is there another way that I could render the data into the form?

boldstar left a reply on API Post To Store Method Return 500 Internal Server Error • 4 days ago

Setting all fillable fields fixed the alarm issue and as far as the EngagementsController I reverted back to this

public function store(Request $request)
    {
        $data = $request->validate([
            'client_id' => 'required|integer',
            'return_type' => 'required|string',
            'year' => 'required|string',
            'status' => 'required|string',
            'assigned_to' => 'required|string',
            'done' => 'required|boolean'
        ]);

        $engagement = Engagement::create([
            'client_id' => $request->client_id,
            'return_type' => $request->return_type,
            'year' => $request->year,
            'assigned_to' => $request->assigned_to,
            'status' => $request->status,
            'done' => $request->done,
        ]);

        return response($engagement, 201);
    }

Thank you, @Snapey, @Cronix, @Tray2

boldstar left a reply on API Post To Store Method Return 500 Internal Server Error • 4 days ago

Perhaps I am getting outside my understand at the moment.. I did notice that I was using postman wrong and trying to pass the form data in the header instead of the body

So now that I am doing that correctly I will show you the error I am getting and perhaps I am headed in a better direction now

this is the error I get back in postman

Illuminate\Database\QueryException: SQLSTATE[HY000]: General error: 1364 Field &#039;return_type&#039; doesn&#039;t have a default value (SQL: insert into `engagements` (`client_id`, `updated_at`, `created_at`) values (1, 2018-09-15 18:51:13, 2018-09-15 18:51:13)) in file C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Database\Connection.php on line 664

This is the setup in my EngagementsController file

public function store(Request $request)
    {
        $data = $request->validate([
            'client_id' => 'required|integer',
            'return_type' => 'required|string',
            'year' => 'required|string',
            'status' => 'required|string',
            'assigned_to' => 'required|string',
            'done' => 'required|boolean'
        ]);

        $engagement = Engagement::create([
            'client_id' => $request->client_id,
            'return_type' => $request->return_type,
            'year' => $request->year,
            'assigned_to' => $request->assigned_to,
            'status' => $request->status,
            'done' => $request->done,
        ]);

        return response($engagement, 201);
    }

This is the Engagement Model

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Engagement extends Model
{
    protected $fillable =
    [
        'client_id'
    ];
    public function client() 
    {
        return $this->belongsTo('App\Client');
    }

    public function engagement_tasks()
    {
        return $this->belongsToMany('App\Task');
    }

}

At first passing the data through the body I was getting a mass assignment alarm as you suggested earlier @Snapey so i added

protected $fillable =
    [
        'client_id'
    ];

is this the correct way to handle the mass assignment issue? I did not get the alarm after applying it...

boldstar left a reply on API Post To Store Method Return 500 Internal Server Error • 4 days ago

@Tray2 , so im still struggling with this I have found an example like below..

public function store($family_id, ContactRequest $request)
{
    $family = Family::findOrFail($family_id);
    $contact = $family->contacts()->create($request->all());

    return $contact;

    //  return redirect('families/' . $family_id);
}

Where they pass the $id first before the request but what I can't grasp is the data that I am sending to the store method from vue front end. Should I be capturing the URL client_id. here is what I have happening on the front end...

This is my form and the url in vue

add-engagement/{client_id}

this is the form

<template>
  <div class="page-wrapper mt-1">
    <div class="add-engagement container">
      <div class="card-body bg-light border-primary mb-2">
        <h4 class="text-left text-primary m-0"><i class="mr-3 far fa-folder-open"></i>New Engagement</h4>
      </div>
        <form @submit.prevent="addEngagement" class="d-flex-column justify-content-center">
          <div class="form-group">
            <select class="form-control mb-3" id="type" v-model="engagement.return_type">
              <option v-for="type in types" :key="type.id" :value="type">{{ type }}</option>
            </select>
            <input type="text" class="form-control mb-3" placeholder="Year" v-model="engagement.year">
            <input type="text" class="form-control mb-3" placeholder="Assign To" v-model="engagement.assigned_to">
            <input type="text" class="form-control mb-3" placeholder="Status" v-model="engagement.status">

            <button type="submit" class="btn btn-lg btn-primary d-flex justify-content-start">Create</button>
          </div>
        </form>
      </div>  
  </div>
</template>

<script>


export default {
  name: 'add-engagement',
  data() {
    return {
      engagement: {
        return_type: null,
        year: '',
        assigned_to: '',
        status: '',
      },
      types: [ 
        'Choose Return Type...', 
        '1040', 
        '1120',
      ],
    }
  },
   methods: {
    addEngagement(e) {
      if(!this.engagement.return_type || !this.engagement.year ){
        return
      } else {
        this.$store.dispatch('addEngagement', {
          id: this.idForEngagement,
          return_type: this.engagement.return_type,
          year: this.engagement.year,
          assigned_to: this.engagement.assigned_to,
          status: this.engagement.status,
        })
        e.preventDefault();
      }
      e.preventDefault();
      this.engagement = "" 
      this.idForEngagement++
      this.$router.push('/engagements')
    },
  },
  created: function() {
    this.engagement.return_type = this.types[0]
  },

}
</script>

and this is the store.js file that is being dispatched to send the request to my laravel api route

addEngagement(context, engagement) {
      axios.post(('/engagements'), {
        return_type: engagement.return_type,
        year: engagement.year,
        assigned_to: engagement.assigned_to,
        status: engagement.status,
        done: false
      })
      .then(response => {
        context.commit('getClientEngagement', response.data)
      })
      .catch(error => {
        console.log(error)
      })
    },

Now notice that the post addEngagement method is mentioning nothing about the client_id.. does it need to be? since the client_id is a foreign_key?

boldstar left a reply on API Post To Store Method Return 500 Internal Server Error • 4 days ago

Okay so I would love to view my laravel log file but I do not know where it is at.. when i try using postman to see what response I get, It does not return a stack to me except after I added the

public function store(Request $request, $client_id)

After I insert the $client_id as a parameter I do get an error response from that...

Symfony\Component\Debug\Exception\FatalThrowableError: Too few arguments to function App\Http\Controllers\EngagementsController::store(), 1 passed and exactly 2 expected in file C:\laragon\www\traxit\app\Http\Controllers\EngagementsController.php on line 53

boldstar left a reply on Form Data Post To Laravel Backend • 4 days ago

@tykus, sorry for the late response

So at this point I am able to capture the ID of the client in the URL. It is not exactly how I intended for it to be structured but none the less it is there

add-engagement\{client_id}

I use my getters from vuex for the client data on that instance..

client(state) {
      return state.client;
    },

So Im not sure what your knowledge is with laravel but how do I know that the client_id is being passed with the rest of the form submission?

this is the AddEngagement component again

 <template>
  <div class="page-wrapper mt-1">
    <div class="add-engagement container">
      <div class="card-body bg-light border-primary mb-2">
        <h4 class="text-left text-primary m-0"><i class="mr-3 far fa-folder-open"></i>New Engagement</h4>
      </div>
        <form @submit.prevent="addEngagement" class="d-flex-column justify-content-center">
          <div class="form-group">
            <select class="form-control mb-3" id="type" v-model="engagement.return_type">
              <option v-for="type in types" :key="type.id" :value="type">{{ type }}</option>
            </select>
            <input type="text" class="form-control mb-3" placeholder="Year" v-model="engagement.year">
            <input type="text" class="form-control mb-3" placeholder="Assign To" v-model="engagement.assigned_to">
            <input type="text" class="form-control mb-3" placeholder="Status" v-model="engagement.status">

            <button type="submit" class="btn btn-lg btn-primary d-flex justify-content-start">Create</button>
          </div>
        </form>
      </div>  
  </div>
</template>

<script>


export default {
  name: 'add-engagement',
  data() {
    return {
      engagement: {
        return_type: null,
        year: '',
        assigned_to: '',
        status: '',
      },
      types: [ 
        'Choose Return Type...', 
        '1040', 
        '1120',
      ],
    }
  },
   methods: {
    addEngagement(e) {
      if(!this.engagement.return_type || !this.engagement.year ){
        return
      } else {
        this.$store.dispatch('addEngagement', {
          id: this.idForEngagement,
          return_type: this.engagement.return_type,
          year: this.engagement.year,
          assigned_to: this.engagement.assigned_to,
          status: this.engagement.status,
        })
        e.preventDefault();
      }
      e.preventDefault();
      this.engagement = "" 
      this.idForEngagement++
      this.$router.push('/engagements')
    },
  },
  created: function() {
    this.engagement.return_type = this.types[0]
  },

}
</script>

and this is the store action

addEngagement(context, engagement) {
      axios.post('http://traxit.test/api/engagements', {
        return_type: engagement.return_type,
        year: engagement.year,
        assigned_to: engagement.assigned_to,
        status: engagement.status,
        done: false
      })
      .then(response => {
        context.commit('getClientEngagement', response.data)
      })
      .catch(error => {
        console.log(error)
      })
    },

Basically at this point when i submit the form with client_id in the url I get a 500 internal server error response...

boldstar left a reply on API Post To Store Method Return 500 Internal Server Error • 4 days ago

Apologies for the late response, @Snapey & @Tray2

@Snapey, im not sure what you mean about 'what is client()?'

the EngagementsController references App\Engagement which is this model below

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Engagement extends Model
{
    public function client() 
    {
        return $this->belongsTo('App\Client');
    }

    public function engagement_tasks()
    {
        return $this->belongsToMany('App\Task');
    }

}

So the client_id is a foreign key on my engagements table...

on the front end i am capturing the id of the client in the URL , but this may be where I am making a mistake..

should there be more parameters being passed on the Engagement model?

boldstar started a new conversation API Post To Store Method Return 500 Internal Server Error • 4 days ago

Hi, i am trying to post a form to my laravel backend but I keep getting a 500 internal server error. Im using a vue frontend with axios to send the post request.

here is my route

Route::post('/engagements', '[email protected]');

here is the EngagementsController for the store method

public function store(Request $request)
    {
        $data = $request->validate([
            'return_type' => 'required|string',
            'year' => 'required|string',
            'status' => 'required|string',
            'assigned_to' => 'required|string',
            'done' => 'required|boolean'
        ]);

        $engagement = Engagement::create([
            'client_id' => client()->id,
            'return_type' => $request->return_type,
            'year' => $request->year,
            'assigned_to' => $request->assigned_to,
            'status' => $request->status,
            'done' => $request->done,
        ]);

        return response($engagement, 201);
    }

and this is the Engagement model it references

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Engagement extends Model
{
    public function client() 
    {
        return $this->belongsTo('App\Client');
    }

    public function engagement_tasks()
    {
        return $this->belongsToMany('App\Task');
    }

}

I believe my issue is coming from the 'client_id' that is being added for the belongsTo() relationship it has with the parent model Client.

Currently my relationships are

  1. User has many Tasks
  2. Task belongs to User
  3. Client has many Engagements
  4. Engagement belongs to Client
  5. Engagement and Tasks have a many to many relationship

So I understand that when I submit data belonging to a user like this

'user_id' => auth()->user()->id,

on the store method it will reference the user model but for some reason that does not work for the client like this

'client_id' => client()->id,

I believe i am missing a step that is telling laravel which client the new engagement belongs to but Im not sure what that step is..

Any help would be greatly appreciated!!!

14th September, 2018

boldstar left a reply on Form Data Post To Laravel Backend • 5 days ago

Okay I will give it a shot and respond back with results later, I have to leave for the moment!

Thank you for your help!

boldstar left a reply on Form Data Post To Laravel Backend • 5 days ago

So would I do a nested route for the client engagements in the router.js file?

Like client/{client_id/add-engagement?

boldstar left a reply on Form Data Post To Laravel Backend • 5 days ago

So workflow of the app would be a User is able to view Clients and from there, view list of Engagements associated with the client. The Engagements will have a relationship with a Task that will be tied back to the User..

boldstar left a reply on Form Data Post To Laravel Backend • 5 days ago

okay so when I VIEW a client, I can see a list of the engagements associated with them only

here is the vue component

<div>
        <div class="header p-0 d-flex flex-row justify-content-between mt-2 mb-4 shadow-sm">
            <i class="ml-3 pr-2 far fa-folder-open h3 text-primary align-self-center m-0"></i>
            <router-link to="/add-engagement" class="mr-3 btn btn-success btn-sm m-0 align-self-center"><i class="mr-2 fas fa-plus-square"></i>Engagement</router-link>
        </div>

        <div class="row mx-1">
            <div class="card mb-3 mr-3 shadow-sm col-4 p-0" v-for="(engagement, index) in engagement" :key="index">
                <div class="d-flex justify-content-between card-header">
                    <h3 class="m-0 text-muted">{{ index + 1 }}</h3>
                    <h5 class="align-self-center m-0"><span>Return Type: </span> {{ engagement.return_type }} </h5>
                </div>
                <div class="card-body text-left p-0 my-1">
                    <h5 class="p-4"><span class="desc">Assigned To: </span> {{ engagement.assigned_to }} </h5>
                    <hr class="my-1">
                    <h5 class="p-4"><span class="desc">Status: </span> {{ engagement.status}} </h5>
                </div>
                <div class="card-footer d-flex justify-content-between">
                    <router-link to="#" class="btn">View</router-link>
                    <router-link to="#" class="btn">Edit</router-link>
                </div>
            </div>
        </div>
    </div>

here is the script for that component

<script>
import { mapGetters } from 'vuex'

export default {
    name: 'client-engagements',
    computed: {
    ...mapGetters(['engagement'])
    },
    created() {
        this.$store.dispatch('getClientEngagement', this.$route.params.id)
    },    
}
</script>

Now notice the the

<router-link to="/add-engagement" class="mr-3 btn btn-success btn-sm m-0 align-self-center"><i class="mr-2 fas fa-plus-square"></i>Engagement</router-link>
        </div>

when i click on that button it takes me to the view for adding a new engagement...

Is this helping you understand or am I not going the right direction?

boldstar left a reply on Form Data Post To Laravel Backend • 5 days ago

I know that the created function probably does not make since right now but my idea was to have the data set to loop through the list of clients in a input but I have not got that far, because I wanted to see if there was a way to add the client_id automatically like as you suggested through the 'URL' maybe?

boldstar left a reply on Form Data Post To Laravel Backend • 5 days ago

well im already retrieving a list of the clients here from the store

retrieveClients(context) {
      this.loading = true
      axios.get('http://traxit.test/api/clients')
      .then(response => {
        this.loading = false
        context.commit('retrieveClients', response.data)
      })
      .catch(error => {
        this.loading = false
        console.log(error)
      })
    },

and if i were doing a list of the clients i had a created function to dispatch that request

created: function() {
    this.engagement.client_id = this.$store.dispatch('retrieveClients')
  },

But as far as how it would know that im adding an engagement for a particular client i am not sure..

boldstar left a reply on Form Data Post To Laravel Backend • 5 days ago

@tykus, It is not related to the authenticated user.

I would prefer to have the client_id already attached to the form when inputting the rest of the data.

But selecting the client from a list of clients would work to, just not ideal for my goal.

Ive seen where laravel will handle the logic of the associated data for the user but im not sure how it will know the association of the table outside of that relationship..

boldstar started a new conversation Form Data Post To Laravel Backend • 5 days ago

Hi, i am trying to submit data to my laravel backend using axios. I need to be able to capture the id of the client that the engagement will be linked to and im struggling to understand how i can access that information so i can send it with the post request.

this is the form component

 <form @submit.prevent="addEngagement" class="d-flex-column justify-content-center">
          <div class="form-group">
            <input type="text" class="form-control mb-3" placeholder="Client" v-model="engagement.client_id">
            <select class="form-control mb-3" id="type" v-model="engagement.return_type">
              <option v-for="type in types" :key="type.id" :value="type">{{ type }}</option>
            </select>
            <input type="text" class="form-control mb-3" placeholder="Year" v-model="engagement.year">
            <input type="text" class="form-control mb-3" placeholder="Assign To" v-model="engagement.assigned_to">
            <input type="text" class="form-control mb-3" placeholder="Status" v-model="engagement.status">

            <button type="submit" class="btn btn-lg btn-primary d-flex justify-content-start">Create</button>
          </div>
        </form>

this is the form component data

engagement: {
        client_id: '',
        return_type: null,
        year: '',
        assigned_to: '',
        status: '',
      },

this is the form component method

 methods: {
    addEngagement(e) {
      if(!this.engagement.client_id || !this.engagement.return_type || !this.engagement.year ){
        return
      } else {
        this.$store.dispatch('addEngagement', {
          id: this.idForEngagement,
          client_id: this.engagement.client_id,
          return_type: this.engagement.return_type,
          year: this.engagement.year,
          assigned_to: this.engagement.assigned_to,
          status: this.engagement.status,
        })
        e.preventDefault();
      }
      e.preventDefault();
      this.engagement = "" 
      this.idForEngagement++
      this.$router.push('/engagements')
    },
  },

Now when i capture the data from here it dispatches my store for the method addEngagement below

addEngagement(context, engagement) {
      axios.post('http://traxit.test/api/engagements', {
        id: engagement.id,
        client_id: engagement.client_id,
        return_type: engagement.return_type,
        year: engagement.year,
        assigned_to: engagement.assigned_to,
        status: engagement.status,
        done: false
      })
      .then(response => {
        context.commit('getClientEngagement', response.data)
      })
      .catch(error => {
        console.log(error)
      })

and sends it the laravel backend to my api route here

Route::post('/engagements', '[email protected]');

From here it would be process by the EngagementsController...

So currently i have the the client_id as a basic input but Im wondering if there is away to capture the id of the client i am trying to create the engagement for because in laravel the engagement will have belongsTo() relationship with the client.

The client id is supposed to be referencing my client table and i dont know how to capture that data without having to manually put it in each time before submitting

this is the controller handling the form post

public function store(Request $request)
    {
        $data = $request->validate([
            'client_id' => 'required|integer',
            'return_type' => 'required|string',
            'year' => 'required|string',
            'status' => 'required|string',
            'assigned_to' => 'required|string',
            'done' => 'required|boolean'
        ]);

        $engagement = Engagement::create([
            'client_id' => $request->client_id,
            'return_type' => $request->return_type,
            'year' => $request->year,
            'status' => $request->status,
            'assigned_to' => $request->assigned_to,
            'done' => $request->done,
        ]);

        return response($engagement, 201);
    }

Hopefully I am being detailed enough on what my issue is. Please as for my more clarity if needed!!

13th September, 2018

boldstar left a reply on Call To Undefined Function App\Http\Controllers\[Name] In File • 6 days ago

Thank you for the help! that did the trick.

boldstar started a new conversation Call To Undefined Function App\Http\Controllers\[Name] In File • 6 days ago

Hi, I am trying to reference the function client() in my Engagement.php model file but when i make a get request to the route I recieve the following error

Symfony\Component\Debug\Exception\FatalThrowableError: Call to undefined function App\Http\Controllers\client() in file C:\laragon\www\traxit\app\Http\Controllers\EngagementsController.php on line 27
Stack trace:
  1. Symfony\Component\Debug\Exception\FatalThrowableError-&gt;() C:\laragon\www\traxit\app\Http\Controllers\EngagementsController.php:27

This is the Engagement.php model file

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Engagement extends Model
{
    public function client() 
    {
        return $this->belongsTo('App\Client');
    }

    public function engagement_tasks()
    {
        return $this->belongsToMany('App\Task');
    }

}

This is the EngagementsController.php file

<?php

namespace App\Http\Controllers;

use App\Engagement;
use Illuminate\Http\Request;

class EngagementsController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        return Engagement::all();
    }

    /**
     * Display a listing of the resource belonging to client.
     *
     * @return \Illuminate\Http\Response
     */
    public function clientindex()
    {
        return Engagement::where('client_id', client()->id)->get();
    }
}

This is the api route i am sending the get request to

Route::get('/client-engagements', '[email protected]');

Any help would be greatly appreciated!!

5th September, 2018

boldstar left a reply on 500 Internal Server Error • 2 weeks ago

Y'all are my hero. It worked. I labeled it as TOKEN instead.

boldstar left a reply on 500 Internal Server Error • 2 weeks ago

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Third Party Services
    |--------------------------------------------------------------------------
    |
    | This file is for storing the credentials for third party services such
    | as Stripe, Mailgun, SparkPost and others. This file provides a sane
    | default location for this type of information, allowing packages
    | to have a conventional place to find your various credentials.
    |
    */

    'mailgun' => [
        'domain' => env('MAILGUN_DOMAIN'),
        'secret' => env('MAILGUN_SECRET'),
    ],

    'ses' => [
        'key' => env('SES_KEY'),
        'secret' => env('SES_SECRET'),
        'region' => env('SES_REGION', 'us-east-1'),
    ],

    'sparkpost' => [
        'secret' => env('SPARKPOST_SECRET'),
    ],

    'stripe' => [
        'model' => App\User::class,
        'key' => env('STRIPE_KEY'),
        'secret' => env('STRIPE_SECRET'),
    ],

];

boldstar left a reply on 500 Internal Server Error • 2 weeks ago

this is what I'm getting when I try my login route.

500 internal server error

https://imgur.com/a/CFOQ2YZ

boldstar left a reply on 500 Internal Server Error • 2 weeks ago

heres an image of the postman request to the /oauth/token route

https://imgur.com/a/ZHBlbSs

boldstar left a reply on 500 Internal Server Error • 2 weeks ago

when i type config('services.passport'), i get back null

boldstar left a reply on 500 Internal Server Error • 2 weeks ago

Im sorry maybe I should have said "form parameters"?

boldstar left a reply on 500 Internal Server Error • 2 weeks ago

And when I use that route in postman plus all the needed headers, I am able to get my response with a token

boldstar left a reply on 500 Internal Server Error • 2 weeks ago

PASSPORT_LOGIN_ENDPOINT="http://traxit.test/oauth/token"

its being stored in the .env file as a variable

boldstar left a reply on 500 Internal Server Error • 2 weeks ago

GuzzleHttp\Exception\RequestException: cURL error 3: <url> malformed (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) in file C:\laragon\www\traxit\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php on line 186 Stack trace:

  1. GuzzleHttp\Exception\RequestException->() C:\laragon\www\traxit\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php:186
  2. GuzzleHttp\Handler\CurlFactory->createRejection() C:\laragon\www\traxit\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php:149
  3. GuzzleHttp\Handler\CurlFactory->finishError() C:\laragon\www\traxit\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php:102
  4. GuzzleHttp\Handler\CurlFactory->finish() C:\laragon\www\traxit\vendor\guzzlehttp\guzzle\src\Handler\CurlHandler.php:43
  5. GuzzleHttp\Handler\CurlHandler->__invoke() C:\laragon\www\traxit\vendor\guzzlehttp\guzzle\src\Handler\Proxy.php:28
  6. GuzzleHttp\Handler\Proxy->GuzzleHttp\Handler{closure}() C:\laragon\www\traxit\vendor\guzzlehttp\guzzle\src\Handler\Proxy.php:51
  7. GuzzleHttp\Handler\Proxy->GuzzleHttp\Handler{closure}() C:\laragon\www\traxit\vendor\guzzlehttp\guzzle\src\PrepareBodyMiddleware.php:66
  8. GuzzleHttp\PrepareBodyMiddleware->__invoke() C:\laragon\www\traxit\vendor\guzzlehttp\guzzle\src\Middleware.php:30
  9. GuzzleHttp\Middleware->GuzzleHttp{closure}() C:\laragon\www\traxit\vendor\guzzlehttp\guzzle\src\RedirectMiddleware.php:70
  10. GuzzleHttp\RedirectMiddleware->__invoke() C:\laragon\www\traxit\vendor\guzzlehttp\guzzle\src\Middleware.php:60
  11. GuzzleHttp\Middleware->GuzzleHttp{closure}() C:\laragon\www\traxit\vendor\guzzlehttp\guzzle\src\HandlerStack.php:67
  12. GuzzleHttp\HandlerStack->__invoke() C:\laragon\www\traxit\vendor\guzzlehttp\guzzle\src\Client.php:277
  13. GuzzleHttp\Client->transfer() C:\laragon\www\traxit\vendor\guzzlehttp\guzzle\src\Client.php:125
  14. GuzzleHttp\Client->requestAsync() C:\laragon\www\traxit\vendor\guzzlehttp\guzzle\src\Client.php:131
  15. GuzzleHttp\Client->request() C:\laragon\www\traxit\vendor\guzzlehttp\guzzle\src\Client.php:89
  16. GuzzleHttp\Client->__call() C:\laragon\www\traxit\app\Http\Controllers\AuthController.php:22
  17. App\Http\Controllers\AuthController->login() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Routing\Controller.php:54
  18. call_user_func_array() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Routing\Controller.php:54
  19. Illuminate\Routing\Controller->callAction() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Routing\ControllerDispatcher.php:45
  20. Illuminate\Routing\ControllerDispatcher->dispatch() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Routing\Route.php:212
  21. Illuminate\Routing\Route->runController() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Routing\Route.php:169
  22. Illuminate\Routing\Route->run() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Routing\Router.php:679
  23. Illuminate\Routing\Router->Illuminate\Routing{closure}() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:30
  24. Illuminate\Routing\Pipeline->Illuminate\Routing{closure}() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Routing\Middleware\SubstituteBindings.php:41
  25. Illuminate\Routing\Middleware\SubstituteBindings->handle() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:151
  26. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
  27. Illuminate\Routing\Pipeline->Illuminate\Routing{closure}() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Routing\Middleware\ThrottleRequests.php:57
  28. Illuminate\Routing\Middleware\ThrottleRequests->handle() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:151
  29. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
  30. Illuminate\Routing\Pipeline->Illuminate\Routing{closure}() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:104
  31. Illuminate\Pipeline\Pipeline->then() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Routing\Router.php:681
  32. Illuminate\Routing\Router->runRouteWithinStack() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Routing\Router.php:656
  33. Illuminate\Routing\Router->runRoute() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Routing\Router.php:622
  34. Illuminate\Routing\Router->dispatchToRoute() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Routing\Router.php:611
  35. Illuminate\Routing\Router->dispatch() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php:176
  36. Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http{closure}() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:30
  37. Illuminate\Routing\Pipeline->Illuminate\Routing{closure}() C:\laragon\www\traxit\vendor\spatie\laravel-cors\src\Cors.php:28
  38. Spatie\Cors\Cors->handle() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:151
  39. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
  40. Illuminate\Routing\Pipeline->Illuminate\Routing{closure}() C:\laragon\www\traxit\vendor\fideloper\proxy\src\TrustProxies.php:57
  41. Fideloper\Proxy\TrustProxies->handle() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:151
  42. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
  43. Illuminate\Routing\Pipeline->Illuminate\Routing{closure}() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php:31
  44. Illuminate\Foundation\Http\Middleware\TransformsRequest->handle() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:151
  45. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
  46. Illuminate\Routing\Pipeline->Illuminate\Routing{closure}() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php:31
  47. Illuminate\Foundation\Http\Middleware\TransformsRequest->handle() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:151
  48. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
  49. Illuminate\Routing\Pipeline->Illuminate\Routing{closure}() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\ValidatePostSize.php:27
  50. Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:151
  51. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
  52. Illuminate\Routing\Pipeline->Illuminate\Routing{closure}() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode.php:62
  53. Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:151
  54. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
  55. Illuminate\Routing\Pipeline->Illuminate\Routing{closure}() C:\laragon\www\traxit\vendor\barryvdh\laravel-cors\src\HandlePreflight.php:29
  56. Barryvdh\Cors\HandlePreflight->handle() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:151
  57. Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php:53
  58. Illuminate\Routing\Pipeline->Illuminate\Routing{closure}() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:104
  59. Illuminate\Pipeline\Pipeline->then() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php:151
  60. Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter() C:\laragon\www\traxit\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php:116
  61. Illuminate\Foundation\Http\Kernel->handle() C:\laragon\www\traxit\public\index.php:55

boldstar left a reply on 500 Internal Server Error • 2 weeks ago

i am able to use the /oauth/token route in post man and recieve the access token but there is something happening when i run the auth controller login logic that is giving me a 500 internal server error

boldstar started a new conversation 500 Internal Server Error • 2 weeks ago

Currently getting 500 internal server error when making a post request. I'm using laravel 5.6 with passport for the access token. running laragon apache server with mysql for the local environment. I have been trying multiple ways to solve the issue.

public function login(Request $request) { $http = new \GuzzleHttp\Client;

    try {
        $response = $http->post(config('services.passport.login_endpoint'), [
            'form_params' => [
                'grant_type' => 'password',
                'client_id' => config('services.passport.client_id'),
                'client_secret' => config('services.passport.client_secret'),
                'username' => $request->username,
                'password' => $request->password,
                ]
                ]);
                return $response->getBody();
            } catch (\GuzzleHttp\Exception\BadResponseException $e) {
                if ($e->getCode() === 400) {
                    return response()->json('Invalid Request. Please enter a username or a password.', $e->getCode());
                } else if ($e->getCode() === 401) {
                    return response()->json('Your credentials are incorrect. Please try again', $e->getCode());
        }
        return response()->json('Something went wrong on the server.', $e->getCode());
    }
}
Edit Your Profile
Update

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