cawex

Experience

19,150

1 Best Reply Awards

  • Member Since 1 Year Ago
  • 151 Lessons Completed
  • 0 Favorites

24th July, 2017

cawex left a reply on Laravel Eloquent Authentication Issue. • 3 days ago

try return view ('stores.show')->withStore($store);

cawex left a reply on Defining Database Tables And It's Pivot Table • 3 days ago

You already store the created_by and updated_by on products, would not mean there is any need to have it on the pivot_table, just seems messy, also I personally like to have a little disturbance as possible, which means you could also just remove the id column if you wish.

14th June, 2017

cawex left a reply on Ideal Way To Generate A Unique Reference Code? • 1 month ago

@MyLibrary No it wouldn't as long as you don't go over that high a number else choose to have 10 digits.

cawex left a reply on Ideal Way To Generate A Unique Reference Code? • 1 month ago

Can't you do something like:

982357881 982357882 982357883 982357884 982357885 982357886 982357887 982357888 982357889 982357891 982357892 so you have a prefix, but it increment on the prefix, if it make sense. You could probably achieve this with substr()

cawex left a reply on Ideal Way To Generate A Unique Reference Code? • 1 month ago

@MyLibrary

So if it's a really small application I think you are safe, but I would not recommend it, PHP's uniqid() is not actually unique, see their php.net here: http://php.net/manual/en/function.uniqid.php

cawex left a reply on Reset Auto Increment After Tests • 1 month ago

So I think your first problem is you are running a test on your production servers rather then it's own environment, it could easily be avoided by using a service like circleCi, travisCI etc. And if it's locally you think it's a problem. Then ask yourself if it really matters and if it's worth spending the time to fix such a little thing, for only local purpose, where you are the only one who sees the ids.

cawex left a reply on Ideal Way To Generate A Unique Reference Code? • 1 month ago

Does it have to increment, in a order that makes sense?

If no then you can look into Ramset\Uuid https://github.com/ramsey/uuid

If you want the increment to make sense, you could do a prefix and then the ID as Snapey is saying.

cawex left a reply on Validation Rule: Allow Only If First Character Is '/' • 1 month ago

Laravel Validator can use regex if I remember correctly, I'm guessing you are using the Laravel validator, as I haven't seen any of your code.

cawex left a reply on Return Redirect After JSON Response Is DONE • 1 month ago

I'm gusseing you are using Guzzle, Right?

$response = $client->put('http://httpbin.org/get', ['future' => true]);

// Call the function when the response completes
$response->then(function ($response) {
    echo $response->getStatusCode();
});

Look into the ->then function see the docs here:

http://docs.guzzlephp.org/en/5.3/clients.html

9th June, 2017

cawex left a reply on UpdateOrCreate() Is NOT My Friend! • 1 month ago

@sdurstling UpdateOrCreate persists the model, so there is no need for calling the save method

14th May, 2017

cawex left a reply on Filter Projects Without Page Refresh. • 2 months ago

It sounds like you want two-way-binding, you could achieve this with a JS framework like React, VueJS(Popular with Laravel), or Anuglar. It's hard to tell which one would benefit you best, you are gonna have to try and google your way to that. But all three frameworks have two way binding.

cawex left a reply on Vujs (vue-cli) + API (laravel) On The Same Domain • 2 months ago

I guess that also could work, I can't really see the benefits of having it all in the same folder. Why not split it up to two applications rather than one=

13th May, 2017

cawex left a reply on Vujs (vue-cli) + API (laravel) On The Same Domain • 2 months ago

It sounds like you just wanna split up your backend, and frontend which is a totally normal way to structure your application, it also give you some benfits like easier to test, a API that are already made in case you need a mobile app etc.

As to how, you would have two different projects app_backend and app_frontend, in the app_backend the entire API logic etc is, and in the app frontend, you would have some calls to the api that fetches and posts the data. And then if you wanna access it on the same domain I would probably make the nameserver/chost point to the /api in the backend

cawex left a reply on Passport Personal Token Unantichated • 2 months ago

Oh god.. I feel stupid..

Thanks @tim_jespers Yes that was the problem :)

cawex left a reply on Passport Personal Token Unantichated • 2 months ago

Hello @tim_jespers

Yes i've edited my config/auth and in my routes/api the middleware im using is auth:api.


Route::group([ 'namespace' => 'App\Api\v1\Controllers', 'middleware' => 'auth:api'], function () {
    Route::get('users', ['as' => 'users.index', 'uses' => [email protected]']);
});

and the config:


    'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'users',
        ],

        'api' => [
            'driver' => 'passport',
            'provider' => 'users',
        ],
    ],

12th May, 2017

cawex started a new conversation Passport Personal Token Unantichated • 2 months ago

Hello, I'm trying to authenticate with personal access token with passport, and I'm about to pull my hair out, i keep getting

esulted in a `401 Unauthorized` response:
{"error":"Unauthenticated."}

I've been searching for an answer in a couple of days now, without any luck.

  1. I've edited my config file
  2. Edited my .htacess
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
  1. I've added auth:api in my routes,
  2. added Passport::routes(); in my authserviceprocider, also tried to add days to the expire, as it seem that has been a problem before.
  3. I tired with both post man, and guzzlegttp

$accessToken = 'dd647196f4faf0feb9e23ce4d094e925fc0685bebeaf75c02b68e03c339257c744ad101e96223999';
        $client = new \GuzzleHttp\Client();

        $res = $client->request('GET', '/api/users',[
                'headers' => [
                    'accept' => 'application/json',
                    'Authorization' => 'Bearer ' . $accessToken
                ]
            ]);


        echo $response->getBody();

I have no idea, what I'm doing wrong hope someone can lead me in the right direction.. Thanks in advance

9th May, 2017

cawex left a reply on Many To Many • 2 months ago

Find the link example

Link::find(1);

Then call the visitor relations and make a count.

Link::find(1)->visitors()->count();

I would think something like that.

26th December, 2016

cawex left a reply on L5.2. Database Seeder Multiple Rows Not Working • 7 months ago

Use factories, quite a simple task you have going on there, also then you won't have to create 50 users by hand.

https://laravel.com/docs/5.3/seeding#using-model-factories

21st December, 2016

cawex left a reply on What's Wrong With My GET? • 7 months ago

Hmmm unfortunately my select nor my ul li is showing. I can see the UL and the Select but not the li and options. Any suggestions to what it can be?

cawex left a reply on What's Wrong With My GET? • 7 months ago

@clay Shoulnd't i be able to loop over my repsonse like this? :

<ul>
  <li  v-for="industry in industries">
    <span>{{industry}}</span>
  </li>
</ul> 

__________________ or

    <el-form-item label="Industry" prop="industries">
      <el-select v-model="ruleForm.industries" placeholder="Industry">
        <el-option  v-for="industry in industries" value="{{industry.id}}">{{industry.name}}</el-option>
      </el-select>
    </el-form-item>

cawex left a reply on What's Wrong With My GET? • 7 months ago

Thanks now I feel stupid :) Thought it was initialized inside the Ruleform as well :)

I've mounted to wrapper and have a script tag at the end of body, Could that be it? I'll look into it Thanks for the help!

cawex started a new conversation What's Wrong With My GET? • 7 months ago

Hey, I'm trying to make a get call that can then show me a select options list, with all the diffrerent industries, from the data fetched. This is how it currently looks:

<template>
<div>{{industries}} test
  <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="120px" class="demo-ruleForm">
    <el-form-item label="Activity name" prop="name">
      <el-input v-model="ruleForm.name" placeholder="Activity name"></el-input>
    </el-form-item>
        <el-form-item label="Activity email" prop="email">
      <el-input v-model="ruleForm.email" placeholder="Activity email"></el-input>
    </el-form-item>
    <el-form-item label="Industry" prop="industries">
      <el-select v-model="ruleForm.industries" placeholder="Industry">
        <el-option v-for="industry in industries" value="shanghai">{{industry}}</el-option>
      </el-select>
    </el-form-item>
      <el-form-item label="Users" prop="user">
      <el-select v-model="ruleForm.user" placeholder="Activity user">
      </el-select>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="handleSubmit">Create</el-button>
      <el-button @click="handleReset">Reset</el-button>
    </el-form-item>
  </el-form>
  </div>
</template>
<script>
  export default {
 props: ['vat'],
   mounted() {
      this.getIndustries();
  },
    data() {
      return {
        ruleForm: {
          name: this.vat && this.vat.owners ? this.vat.owners[0].name : '',
          industries: {},
          email: '',
          user: ''
        },
        rules: {
          name: [
            { required: true, message: 'Please input Activity name', trigger: 'blur' }
          ],
          industries: [
            { required: true, message: 'Please select Activity zone', trigger: 'change' }
          ],
          user: [
            { required: true, message: 'Please select a user', trigger: 'change' }
          ],
          email: [
            { required: true, message: 'Please input email', trigger: 'change' }
          ]
        },
     }
    },
    methods: {
      handleReset() {
        this.$refs.ruleForm.resetFields();
      },
      getIndustries() {
          this.$http.get('industries').then((response) => {
              this.industries = response.data;
        console.log(this.industries);
            }, (response) => {
              // error callback
            }).bind(this);
      },
      handleSubmit(ev) {
        this.$refs.ruleForm.validate((valid) => {
          if (valid) {
            alert('submit!');
          } else {
            console.log('error submit!!');
            return false;
          }
        });
      }
    },
  }
</script>

But I get the warnings:

[Vue warn]: Templates should only be responsible for mapping the state to the UI. Avoid placing tags with side-effects in your templates, such as <script>. 

[Vue warn]: Property or method "industries" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option. 
(found in component <clientform> at C:\xampp\htdocs\Flarepoint-crm\resources\assets\js\components\Clientform.vue)

The response looks like this:

{"id":1,"name":"Accommodations"},{"id":2,"name":"Accounting"},{"id":3,"name":"Auto"},{"id":4,"name":"Beauty & Cosmetics"},{"id":5,"name":"Carpenter"},{"id":6,"name":"Communications"},{"id":7,"name":"Computer & IT"},{"id":8,"name":"Construction"},{"id":9,"name":"Consulting"},{"id":10,"name":"Education"},{"id":11,"name":"Electronics"},{"id":12,"name":"Entertainment"},{"id":13,"name":"Food & Beverages"},{"id":14,"name":"Legal Services"},{"id":15,"name":"Marketing"},{"id":16,"name":"Real Estate"},{"id":17,"name":"Retail"},{"id":18,"name":"Sports"},{"id":19,"name":"Technology"},{"id":20,"name":"Tourism"},{"id":21,"name":"Transportation"},{"id":22,"name":"Travel"},{"id":23,"name":"Utilities"},{"id":24,"name":"Web Services"},{"id":25,"name":"Other"}]

17th December, 2016

cawex left a reply on Create A Chart With Vue • 7 months ago

@ejdelmonico Chart =

chart: function (item, config) {
        this.controller = new Chart.Controller(item, config, this);
        return this.controller;
    }

this =

[object Object]

cawex left a reply on Create A Chart With Vue • 7 months ago

That sounds correct :)

cawex left a reply on Create A Chart With Vue • 7 months ago

@jekinney This is what I have now, I remove the vue.extend, but it didn't work. Any other suggestions?

<template>
    <canvas width="730" ref="canvasline"></canvas>
</template>

<script>
import Chart from 'chart.js';

    export default {
        props: ['values', 'labels', 'valuesextra'],
        render(data)
        {
        this.Chart = new Chart(this.$refs.canvasline.getContext('2d'), {
            type: 'line',
            data: {
            labels: this.labels,
            datasets: [
                {
                    label: 'Created',
                    fillColor: "rgba(151,187,205,0.2)",
                    strokeColor: "rgb(58,72,92)",
                    pointColor: "rgba(58,72,92,1)",
                    pointStrokeColor: "#fff",
                    pointHighlightFill: "#fff",
                    pointHighlightStroke: "rgba(220,220,220,1)",
                    data: this.values
                },
                {
                    label: 'Completed',
                    fillColor: "rgba(151,187,205,0.2)",
                    strokeColor: "rgba(60,141,188,0.8)",
                    pointColor: "#3b8bba",
                    pointStrokeColor: "rgba(60,141,188,1)",
                    pointHighlightFill: "#fff",
                    pointHighlightStroke: "rgba(60,141,188,1)",
                    data: this.valuesextra
                },
            ]
            }
        });
        },
        mounted() {
            console.log('chart: ' + Chart);
        }
    };
</script>

cawex left a reply on Create A Chart With Vue • 7 months ago

I will check that out, I seem to be out of all my errors. I'm not sure what you mean exactly by making sure my "canvasline is creating the chart"

<canvas width="730" ref="canvasline"></canvas>

this.Chart = new Chart(this.$refs.canvasline.getContext('2d'), {

is it this part we are talking about?

cawex left a reply on Create A Chart With Vue • 7 months ago

Graphline is currently my only component yes... I changed v-el to ref. I guess my problem is I'm trying to follow laracasts tutorial but Jeffrey is using Vue 1. Changing it removed the errors i have (Think it was that)

When i look in vue dev tools i can see my comp and it's data

labels: Array[13] prop
0: "December"
1: "January"
2: "February"
3: "March"
4: "April"
5: "May"
6: "June"
7: "July"
8: "August"
9: "September" ...
values: Array[13] prop
0: 8
1: 12
2: 17
3: 12
4: 18
5: 17
6: 16
7: 21
8: 9
9: 9 ...
valuesextra: Array[13] prop
0: 4
1: 11
2: 5
3: 6
4: 5
5: 5
6: 5
7: 14
8: 7
9: 8

But there are still nothing showing,

cawex left a reply on Create A Chart With Vue • 7 months ago

Thanks @craigpaul and @ejdelmonico. It unfortunately did not make it show.

This is what i have now:

<template>
    <canvas width="730" v-el:canvasline></canvas>
</template>

<script>
import Chart from 'chart.js';

    export default Vue.extend({
        props: ['values', 'labels', 'valuesextra'],
        render(data)
        {
        this.Chart = new Chart(this.$els.canvasline.getContext('2d'), {
            type: 'line',
            labels: this.labels,
            datasets: [
                {
                    label: 'Created',
                    fillColor: "rgba(151,187,205,0.2)",
                    strokeColor: "rgb(58,72,92)",
                    pointColor: "rgba(58,72,92,1)",
                    pointStrokeColor: "#fff",
                    pointHighlightFill: "#fff",
                    pointHighlightStroke: "rgba(220,220,220,1)",
                    data: this.values
                },
                {
                    label: 'Completed',
                    fillColor: "rgba(151,187,205,0.2)",
                    strokeColor: "rgba(60,141,188,0.8)",
                    pointColor: "#3b8bba",
                    pointStrokeColor: "rgba(60,141,188,1)",
                    pointHighlightFill: "#fff",
                    pointHighlightStroke: "rgba(60,141,188,1)",
                    data: this.valuesextra
                },
            ]
        });
        },
        mounted() {
            options = {
                responsive: true,
                maintainAspectRatio: false,
            };
        }
    });
</script>

and these errors in my console log:

[Vue warn]: Failed to resolve directive: el 

(found in anonymous component - use the "name" option for better debugging messages.)

Not sure how to resolve it. And if I'm including the chart.js correct, is there a way to test that? Vue is 2.16

16th December, 2016

cawex started a new conversation Create A Chart With Vue • 7 months ago

Hello, I'm following Laracasts chart / VueJs tutorial, and have run into a little problem. I have included chart.js with npm, but I'm not getting any chart to show. But I can see my competent in the Vuejs debugger tool.

This is what I've done:

  1. npm install chart.js
  2. in my .vue file
<template>
    <canvas width="730" v-el:canvasline></canvas>
</template>

<script>
import Chart from 'chart.js';

    export default Vue.extend({
        name:'test',
        props: ['values', 'labels', 'valuesextra'],
        data(){
            return {};
        },
        ready() 
        {
            options = {
                responsive: true,
                maintainAspectRatio: false,
            };
        },
        render(data) 
        {
            this.Chart = new Chart(
                this.$els.canvasline.getContext('2d')
            ).Line(
            labels: this.labels,
            datasets: 
            [
                {
                    label: 'Created',
                    fillColor: "rgba(151,187,205,0.2)",
                    strokeColor: "rgb(58,72,92)",
                    pointColor: "rgba(58,72,92,1)",
                    pointStrokeColor: "#fff",
                    pointHighlightFill: "#fff",
                    pointHighlightStroke: "rgba(220,220,220,1)",
                    data: this.values
                },
                {
                    label: 'Completed',
                    fillColor: "rgba(151,187,205,0.2)",
                    strokeColor: "rgba(60,141,188,0.8)",
                    pointColor: "#3b8bba",
                    pointStrokeColor: "rgba(60,141,188,1)",
                    pointHighlightFill: "#fff",
                    pointHighlightStroke: "rgba(60,141,188,1)",
                    data: this.valuesextra
                },
            ]);
        }
    });
</script>
  1. in my view
<graphline class="chart" :labels="{{json_encode($createdTaskEachMonths)}}"
                              :values="{{json_encode($taskCreated)}}"
                              :valuesextra="{{json_encode($taskCompleted)}}"></graphline>
  1. my instance and compontent include in app.js
Vue.component('graphline', require('./components/Graphline.vue'));

var app = new Vue({
    el: '#wrapper',
    components: ['graphline']
});
  1. Run gulp in command line

It guess i must have done something wrong somewhere. I', thinking in my include of chart.js?

4th December, 2016

cawex left a reply on Testing Without 'real Data' • 7 months ago

@xtremer360 Yeah i agree, but it does not solve my current problem, that I have to generate the user each time I run a test.

29th November, 2016

cawex left a reply on Testing Without 'real Data' • 7 months ago

Thank you @ifpingram That might work, Gonna test it over the weekend. Thanks!

27th November, 2016

cawex left a reply on Testing Without 'real Data' • 8 months ago

@lars6 I'm not sure how that helps me in this very case, can you point me in a more specific direction?

cawex started a new conversation Testing Without 'real Data' • 8 months ago

Hello, so I started testing my open-source project, but I'm a bit troubled with how to do it, as I don't know which data the user has in the DB, so I'm using database transactions, for each test, but seeing as I have to create a user each time with a role and the different permissions each test takes longer then it should

For example, I'm currently doing this in every test case, to create a user that has all permissions:

  $user = new User;
        $user->name = 'Username';
        $user->email = [email protected]';
        $user->password = bcrypt('admin');
        $user->save();

        $adminRole = new Role;
        $adminRole->display_name = 'Test role';
        $adminRole->name = 'Test Role';
        $adminRole->description = 'Role for testing';
        $adminRole->save();

        $newrole = new RoleUser;
        $newrole->role_id = $adminRole->id;
        $newrole->user_id = $user->id;
        $newrole->timestamps = false;
        $newrole->save();

        $createUser = new PermissionRole;
        $createUser->role_id = $adminRole->id;
        $createUser->permission_id = '1';
        $createUser->timestamps = false;
        $createUser->save();

        $updateUser = new PermissionRole;
        $updateUser->role_id = $adminRole->id;
        $updateUser->permission_id = '2';
        $updateUser->timestamps = false;
        $updateUser->save();

        $deleteUser = new PermissionRole;
        $deleteUser->role_id = $adminRole->id;
        $deleteUser->permission_id = '3';
        $deleteUser->timestamps = false;
        $deleteUser->save();

        $createClient = new PermissionRole;
        $createClient->role_id = $adminRole->id;
        $createClient->permission_id = '4';
        $createClient->timestamps = false;
        $createClient->save();

        $updateClient = new PermissionRole;
        $updateClient->role_id = $adminRole->id;
        $updateClient->permission_id = '5';
        $updateClient->timestamps = false;
        $updateClient->save();

        $deleteClient = new PermissionRole;
        $deleteClient->role_id = $adminRole->id;
        $deleteClient->permission_id = '6';
        $deleteClient->timestamps = false;
        $deleteClient->save();

        $createTask = new PermissionRole;
        $createTask->role_id = $adminRole->id;
        $createTask->permission_id = '7';
        $createTask->timestamps = false;
        $createTask->save();

        $updateTask = new PermissionRole;
        $updateTask->role_id = $adminRole->id;
        $updateTask->permission_id = '8';
        $updateTask->timestamps = false;
        $updateTask->save();

        $createLead = new PermissionRole;
        $createLead->role_id = $adminRole->id;
        $createLead->permission_id = '9';
        $createLead->timestamps = false;
        $createLead->save();

        $updateLead = new PermissionRole;
        $updateLead->role_id = $adminRole->id;
        $updateLead->permission_id = '10';
        $updateLead->timestamps = false;
        $updateLead->save();

What I was wondering was if I could.

  1. Implement this in some way, i don't have to put it in all my test cases. As it does get messy.
  2. Migrate this in the start of the test only, and then remove the data when all test is done, so I dont have to seed at each test.

11th September, 2016

cawex left a reply on How To Actually Update Laravel 5.3 • 10 months ago

Maatwebsite dosen't need Laravel 5.3, for what i know i dosen't support 5.3 yet, which is also what the error is saying. This is something the developer of the package define in his composer file, what is supported/required to run the package. so either you have to wait, or use something else.

20th August, 2016

cawex left a reply on Vue-Table/vue-resoruce Ajax POST, And Get Response.data • 11 months ago

@ratiw yeah saw on github i will test it out later, and see if i can get it to work! Thanks :)

12th August, 2016

cawex left a reply on Resource Controllers And Additional Parameters • 11 months ago

I'm fairly certain you can just go in your routes like this:

Route::get('some/url/{param1}/{param2}/{param3}', [email protected]')->name('aName');

And then you can call it:

<a href="{{ route('aName . $param1 . '/' . $param2. '/'.$param3 }}" title="Edit signature">

Be aware this code is not tested. But I do believe that's the correct approach

11th August, 2016

cawex left a reply on Vue-Table/vue-resoruce Ajax POST, And Get Response.data • 11 months ago

@ratiw

Yes, this is how i ended up doing it (and for others)

                @ifUserCan('user.delete|user.edit') 
                :item-actions="clientsItemActionDeleteEdit"
                    @elseifUserCan('user.delete')
                :item-actions="clientsItemActionDelete"
                    @elseifUserCan('user.edit')
                :item-actions="clientsItemActionEdit"
                    @else
                :item-actions="clientsItemActionView"
                @endif

and then in the "clientsItemActionDelete" I will not call the this-edit for example... Hope too see a better way of doing this in a later version :)!

cawex left a reply on Vue-Table/vue-resoruce Ajax POST, And Get Response.data • 11 months ago

@ratiw Seems like a bit of a hack :) Also if a user can do both edit, and delete for example. it will use the last if, so you have had to do something like... if the user can delete && can edit && can watch then... and if the user can delete only then... etc, to sort all possibilities of what a user can do. see where I'm getting at? I guess it's not possible as it is atm also gonna be one messy Vue file :)

  • Thanks for the suggestion though

10th August, 2016

cawex left a reply on Vue-Table/vue-resoruce Ajax POST, And Get Response.data • 11 months ago

Ah, I see, @ratiw is it possible to extend two :item-actions to the vue-table? As I want to show some of the actions if a user has the permission. for example

                @ifUserCan('user.delete') 
                :item-actions="clientsItemActionDelete"
                @endif 
        @ifUserCan('user.edit') 
                :item-actions="clientsItemActionEdit"
                @endif 
        @ifUserCan('user.watch') 
                :item-actions="clientsItemActionWatch"
                @endif 

And all three can be active at the same time ofc.

9th August, 2016

cawex left a reply on Vue-Table/vue-resoruce Ajax POST, And Get Response.data • 11 months ago

@ratiw Fair enough, I will look into it. One last question(sorry for all the questions (Also I just realised right now as I was searching in the documentary that you are the creator :) Good job)) I have a column called company_name, if I wanna include it in the search how would I go about that, currently it's only looking for the email and name.

            setFilter: function() {
                this.moreParams = [
                    'filter=' + this.searchFor
                ]
                this.$nextTick(function() {
                    this.$broadcast('vuetable:refresh')
                })
            },
            resetFilter: function() {
                this.searchFor = ''
                this.setFilter()
            },
  • Thanks again

cawex left a reply on Vue-Table/vue-resoruce Ajax POST, And Get Response.data • 11 months ago

Got it to work with

Vue.http.headers.common['X-CSRF-TOKEN'] = document.querySelector('#token').getAttribute('value');

Apparently it dindt wanna find it by the name i guess? But thank you @ratiw

8th August, 2016

cawex left a reply on Vue-Table/vue-resoruce Ajax POST, And Get Response.data • 11 months ago

@ratiw

Do you mean like this?

      clientDeleteProfile: function(id) {
        
        this.$http.delete('clients/'+id, function() {
          headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }

        }
      )
      window.location.href = "clients";
      },

Can't get that to work either, I've tried that as well, but with no luck, unfortunately :/

7th August, 2016

cawex started a new conversation Vue-Table/vue-resoruce Ajax POST, And Get Response.data • 11 months ago

Hello Laracast, I tried out Vue-table (https://github.com/ratiw/vue-table) And like it so far, I do have few questions, not so much to vue-tables alone. But in my table, i wanna give the option to delete a user directly from the table and I'm getting the correct id and everything but have CSRF problem. I've tried a couple of different things so far.

in my method:
      deleteProfile: function(id) {
        Vue.http.headers.common['X-CSRF-TOKEN'] = $('meta[name="csrf-token"]').attr('content');
        this.$http.delete('clients/'+id, function() {

        }
        
      )
      //window.location.href = "clients";
      },

I've tried to pass it with http-data on the vue table it self and just inserting the meta tag over the form, but can't get it to work

My view 
<meta id="_token" value="{{ csrf_token() }}"> 
<vue table
http-data:"{{ csrf_token() }}"
> </vuetable>

The second is i wanna have one of the columns as links so I'm trying this:
The colum

{ name: 'name', sortField: 'name', callback: 'name' },

My method:
  name: function(value)
  {
    return value = value;
  },

The event where i wanna get the id

'vuetable:load-success': function(response) { this.dataset = response.data this.id = this.dataset.data.id console.log(this.dataset.industry_id) }


But i am just getting undefined on the console.log, 

Hope someone can help me.. Thanks in advance

22nd July, 2016

cawex left a reply on My CRM Is Online Now, Hoping For Some Feedback • 1 year ago

@ZetecVan I've got it to work! I thank you for the help, it is pushed and up and running :)

@sadhakbj Do you mean doc blocks, or the session flash message? :) Well otherwise both are missing, the flash message is an error, and more comment/doc blocks are on the to-do, but thank you!

cawex left a reply on My CRM Is Online Now, Hoping For Some Feedback • 1 year ago

@jlrdw Thank you, that actually kind of relieved me, even though I knew it, hearing it made sense :)

@jaydeluca Thank you very much, I appreciate it.

@ZetecVan Thanks, i will look into it later, see if I can get it work, it make sense they way you tell it, let's hope I can do it in practice.

@jekinney Makes a lot of sense, but I guess it's also a lot about just being strict and stick to the pattern you chose then. With the dashboard, where would you create the method that returns a collection? Which approach would you take to do it? I don't totally follow there I have to admit, any examples of some sort?

21st July, 2016

cawex left a reply on My CRM Is Online Now, Hoping For Some Feedback • 1 year ago

@ZetecVan ofc, it's:

Tasks.show (https://github.com/Bottelet/Flarepoint-crm/blob/master/resources/views/tasks/show.blade.php#L20) Clients.show (https://github.com/Bottelet/Flarepoint-crm/blob/master/resources/views/clients/show.blade.php#L39) User.show (https://github.com/Bottelet/Flarepoint-crm/blob/master/resources/views/users/show.blade.php#L22)

as you can see they all have the same header but, the data is retrieved differently, as in tasks, for example, it has to get the User and Client that are assigned the task, so it goes through the task model, to get the associated user, and client. Does it make sense ?

cawex left a reply on My CRM Is Online Now, Hoping For Some Feedback • 1 year ago

@ZetecVan Okay I didn't totally figure it out, the current problem is that I have copied for example the part where you can see the client info and user info(the header) into each view, and I get the data like this in the tasks view fx:

$client->userAssignee->name
$task->assigned->name

As I have to get the name of the user who is assigned the client or task, or the client assigned the task etc. I guess I can't really do this with a view composer, as the data is fairly dynamic, I would have to have a view composer for each blade template? or how would you go about it?

cawex left a reply on My CRM Is Online Now, Hoping For Some Feedback • 1 year ago

@ZetecVan Just gonna hijack, my own thread here to ask for help. I tried doing the view composer thing, but running into a little bit of trouble. this is how I've done it.

My viewComposerServiceProvider:

    public function boot()
    {
        view()->composer(
            'clients.index', 'App\Http\ViewComposers\ClientHeaderComposer'
        );
    }

on the clients index page i have included it like this:

@include('partials.clientheader')

and in my clientHeaderComposer I've done this:

    public function compose(View $view)
    {
        $view->with('client', $this->clients->find(1));
    }

and it does show, but the rest of the page dosen't render for some reason, not sure where it goes wrong, hope you can help me :)

20th July, 2016

cawex left a reply on My CRM Is Online Now, Hoping For Some Feedback • 1 year ago

@andrewclark, I'll try to give abstract classes a look as well. It's funny to see how people are doing things differently. @zachleigh Thank you for the recommendation, I will give it a look, what you are saying with validating if it needs to scale etc, makes a lot of sense, but as this is mostly a learning project for me, I am trying out different approaches, and not so worried if it really needs to be able to scale atm.. @SaeedPrez Thanks for the input, I use my models mostly for simple eloquent(hasMany, belongsTo etc) commands, Dunno, if it just better when it's a small application to insert the logic into the models?

Thanks for all the input! Nice to hear the different approaches people would be taking.

cawex left a reply on My CRM Is Online Now, Hoping For Some Feedback • 1 year ago

@zachleigh, I see that makes sense, but isn't repositories, a good thing to have in case of app scaling? I'm not saying my CRM is gonna be the new Salesforce or anything, but rather than having everything in the controller like I did?, it seems like it gives way more flexibility. I see how the Interface might have been a bit overkill.

Edit Your Profile
Update

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