kayintveen

kayintveen

Member Since 4 Years Ago

Rotterdam

Founder @ Microdesign at The Hague

Experience Points 20,155
Experience Level 5

4,845 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 192
Lessons
Completed
Best Reply Awards 1
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

22 Mar
3 days ago

kayintveen started a new conversation Starting A New Application, Choices For Frontend. Laravel Itself, React, Vue And So On

Hi all,

Since i haven't been working on Laravel for over a year now. Im a little doubting the route i want to take. I'm planning a new small saas project as side project to manage some subscription stuff.

This will be in phase 1 just a web base app and later connected to ios / andoird (react native) app.

Im not sure what i want to use. Since im working on the PWA/Magento/React route anyway its either laravel itself (routes of laravel and blade templates probably with a few react components inside) or a complete SPA (react, next or just react)

What do you guys think the best route is, also taking in to account everything needs to be api-first anyways due to the coming ios/android stuff.

A complete spa will add some complexity and extra development time though

30 May
1 year ago

kayintveen left a reply on Since Laravel Mix PhpStorm Become Slow When Watch Is Running

Same here. I already only included the folders i use for custom or changed code. No changes.

24 Mar
2 years ago

kayintveen left a reply on Updating A Value Of A Child Component Inside A List Compnent

Super, many many thanks. i knew this was the way to do it. i also struggle with the emit function which seems to be more commenly used for these kinds of issues, but this works now. many thanks.

23 Mar
2 years ago

kayintveen started a new conversation Updating A Value Of A Child Component Inside A List Compnent

Hi all,

I'm a little stuck. I made a component that lists categories. Inside that list a new component gets loaded with a autocomplete function.

This works perfectly, but i have trouble updating the current object.

Below you see my code. the :on-select="getData" triggers a getData method that posts back the json object that is selected in the autocomplete. thats great., but now i need to process that response.id to category.category_id.

This works hardcoded via: this.categories[0].category_id = response.id; but i need the index to be dynamic. but i can't get my head around it.

<template>

    <div>
        <div class="tablecontent-row white" v-if="categories">
            <table>
                <thead>
                    <tr>
                        <th>Field</th>
                        <th>Filter</th>
                        <th>Value</th>
                        <th>Category</th>
                    </tr>
                </thead>
                <tbody>

                    <tr v-for="category in categories">
                        <td>
                            <select v-model="category.field">
                                <option v-for="field in fields" :value="field">{{field}}</option>
                            </select>
                        </td>
                        <td>
                            <select v-model="category.filter">
                                <option v-for="filter in filters" :value="filter">{{ filter }}</option>
                            </select>
                        </td>
                        <td><input type="text" v-model="category.value"></td>
                        <td>
                            
                            <input type="text" v-model="category.category_id">
                            
                            <autocomplete
                                    name="label"
                                    url="/search_categories/FeedBeslist/"
                                    anchor="label"
                                    label="name"
                                    :on-select="getData"
                                    :initValue="category.category.label">
                            </autocomplete>

                        </td>
                    </tr>

                </tbody>
            </table>

        </div>

        <div class="panel-row no_entries white" v-else>
            No categories set
        </div>
    </div>

</template>

<script>
    import autocomplete from 'vue2-autocomplete-js';

    export default {
        components: {
            'autocomplete': autocomplete,
        },
        props: [ 'id', 'fields', 'filters' ],
        data: function () {
            return {
                ///running: false,
                categories: '',
                category_id: null
            }
        },
        mounted () {

            axios.get('/feeds/' + this.id + '/get_categories')
                .then(function (response) {
                    this.categories = response.data;
                }.bind(this));


        },
        computed (){

        },
        methods: {
            getData (response) {

                 this.categories[0].category_id = response.id;
            }
        },
        ready () {


        }
    }
</script>
15 Mar
2 years ago

kayintveen started a new conversation Since Laravel Mix PhpStorm Become Slow When Watch Is Running

Does anyone else has this issue as well. I notice my Phpstorm becomes laggy and slow when npm run watch is running in the background. Any clue why this is.

When still using gulp watch no issues!

07 Mar
2 years ago

kayintveen started a new conversation Transform / Change Data From Eloquent Without Saving New Values

Hi all,

Im working on a data processor which runs trough modifiers and filters and does certain actions to them. Example, we have product. and all products with stock < 3 set value stock_status to out of stock.

(in the db its in stock) But i do not want to save this to the database.

So something like: Raw data -> processor -> new data Since the raw data can be processed different ways for different outcomes, the raw data needs to be like it was. I was also thinking about making a extra db table that stores that data to a seperate table. But having 100.000 products and 10 outputs. you already have 1mljn records.

I was trying something like this

$query->each(function($product){
    if($product->stock < 3)
        $product->stock_status = 'out of stock';
});

but that does not work.

21 Feb
2 years ago

kayintveen started a new conversation Queue Workers Restart Automatically Upon Deploy?

I noticed that its important to stop and restart your queue workers when the code of those queue jobs changed. Else it keeps executing old code.

(i find it a little strange but happened more then once) Does envoyer reset / restart the workers automatically upon deploy? I currently have 4 workers running simultaneously via supervisorctl. when stopping and starting i need my sudo passsword so there is no easy way to add this to the deploy scripts

20 Feb
2 years ago

kayintveen left a reply on Queueable Job Failed() Must Be An Instance Of App\Jobs\Exception Issue

This has been magically solved. i just removed the exception since im not using it at all. I just need to know if a process is running or not.

thanks

    public function failed()
    {
        $this->feed_connection->scheduled = 0;
        $this->feed_connection->running = 0;
        $this->feed_connection->failed = 1;
        $this->feed_connection->last_failed_date = Carbon::now();
        $this->feed_connection->save();
        event(new FinishedProductImport($this->feed_connection, 'failed'));
    }
19 Feb
2 years ago

kayintveen started a new conversation On A Queue Job 2 Events (begin And End) Both Trigger At Same Time.

I have a queue job that processed a product import. On that handle method i have a event that triggers pusher to broadcast a "running" event. While on the bottom there is a event that sends a "finished" status to that same channel.

When importing 8.000 products that takes a of course a few seconds. so why are they both send at the same time.

    public function handle(xmlParser $xmlParser, Product $product)
    {
        event(new FinishedProductImport($this->feed_connection, 'running'));
    $products = $this->feed_connection->startImport();
    $products->each(function($product){
        new productImporter($product)->processImport();
    });
        event(new FinishedProductImport($this->feed_connection, 'finished'));
    }

17 Feb
2 years ago

kayintveen started a new conversation Queueable Job Failed() Must Be An Instance Of App\Jobs\Exception Issue

Hi all,

I have a queueable job which might fail sometimes. When it fails i need a few records to be updated in the initial model that is used.

in the job class i added a failed method

public function failed(Exception $exception)
    {
        $this->feed_connection->scheduled = 0;
        $this->feed_connection->running = 0;
        $this->feed_connection->failed = 1;
        $this->feed_connection->last_failed_date = Carbon::now();
        $this->feed_connection->save();
    }

But when i use this i get several errors like:

local.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Type error: Argument 1 passed to App\Jobs\processXmlConnection::failed() must be an instance of App\Jobs\Exception, instance of Symfony\Component\Debug\Exception\FatalThrowableError given

and

local.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Type error: Argument 1 passed to App\Jobs\processXmlConnection::failed() must be an instance of App\Jobs\Exception, instance of Nathanmac\Utilities\Parser\Exceptions\ParserException given

Probably something missing here but i tried everything. Anybody got a clue?

20 Dec
2 years ago

kayintveen left a reply on Valet Not Working With Php7.0 Valet.sock "No Such File Or Directory"

Thanks indeed not sure if the composer was the one helping or the valet install.. Thanks!

now just left with this error

mcrypt_module_open(): Could not open encryption module

php70-mcrypt is installed and enabled. but still not working :( reinstalling no solution

19 Dec
2 years ago

kayintveen started a new conversation Valet Not Working With Php7.0 Valet.sock "No Such File Or Directory"

When i tried installing php70 over brew my valet gives an error (502 bad gateway) in nginx logs i see this:

*4 connect() to unix:/Users/USER/.valet/valet.sock failed (2: No such file or directory) while connecting to upstream

When i unlink php70 en link php71 again it all works fine.

in ~/.valet/ dir the valet.sock does not get generated when starting or restarting Valet.

but after brew unlink php70 brew link php71 valet restart it does.

what am i doing wrong, i already tried installing php7 with fpm and also from source

19 Nov
2 years ago

kayintveen left a reply on Filtering Trough Big Arrays, Collections Vs Looping Through Mysql Performance Choice

It's not about showing but more about processing the data.

kayintveen started a new conversation Filtering Trough Big Arrays, Collections Vs Looping Through Mysql Performance Choice

Hi all,

I'm creating a filter tool to filter e-commerce products down.. Meaning the user can choose multiple filters and manipulate, include or exclude data.

So for now i have a rules table, and of course a products table. The rules can have maybe 10, maybe 50 rules (if price < 10 exclude) (if price > 100 change attribute shipping to 0) Those kinds of filters.

But when it involves 100.000 or maybe in some cases 500.000 products. What would be the best practices. Somehow you fetch the rules onces. thats no harm. Then you need to loop through these filters product by product.

Its should be a on the fly thing, since the core value should be kept but after the filter it will either store the products in a xml, csv or send over through a api.

Products -> Filter -> Api.

The problem i have is performance of course. Doing it the most basic dumb way would be looping each product through the filters and then perform the send action (either api, or write to file)

But is it smart to select 500.000 at once, make one big object or array. or do this in batches. Whats your opinion / view on this?

10 Nov
2 years ago

kayintveen left a reply on Aproach For Structuring Classes That Are Fairly Similar But Not Quite

Thank for your response. What i now did is i made a connections folder where my entities are inside. These entities got public properties called "attributes" These attributes contain for example

public $attributes = [
        'api_key' => 'string',
        'api_secret' => 'string',
    ];

These generate string input fields in my create file. these files have a structures classname and filename. So i only have to create a new class with the same prefix but different name and im able to store new attributes for a different model entity.

These entities can then be expanded upon specific specification. but are thus very flexible. Not sure if this is a one of the dozen design best practices but feels lot more structured then made before.

kayintveen started a new conversation Aproach For Structuring Classes That Are Fairly Similar But Not Quite

I'm stuck procrastinating how to approach the following, and since its something i expect is not easy to refactor later i like anybodies advice on this. Currently i am creating a small app that connects to 3rd party services. They all use products to be send to these services so in general the functionality around each service will be the same but not really. So first of all each service has its own specifications.

Service A

  • ID
  • Name
  • Api Key
  • Api Secret

Service B

  • ID
  • Name
  • FTP User
  • FTP Password

So first question is i want to create a "services" model but its a little dumb i think to make db columns for api key, secret and ftp credentials. since there will be probably be 100 services in the end and while id and name are always applicable the fields can very. I'm thinking of storing this as metadata json inside a "credentials" json db column. But im not sure if thats the correct path. Also i need to somewhere specify the needed fields per service.

also connected to that there will be other functions connected to send the products. one will create a xml file the other a csv another will push to api or upload a file to the ftp. I'm a little afraid of making different models for these. Or making different classes for each. but i think its the way to go right?

kayintveen left a reply on Livereload Not Working With 5.3 Version Of Elixer?

Just for the searchers. I mixed things up with browsersync. Currently using that and works fantastic. This is my code now

const elixir = require('laravel-elixir');

require('laravel-elixir-vue');
require('laravel-elixir-livereload');

/*
 |--------------------------------------------------------------------------
 | Elixir Asset Management
 |--------------------------------------------------------------------------
 |
 | Elixir provides a clean, fluent API for defining some basic Gulp tasks
 | for your Laravel application. By default, we are compiling the Sass
 | file for our application, as well as publishing vendor resources.
 |
 */

elixir(mix => {
     mix.sass('app.scss')
        .webpack('app.js')
        .scripts([
             'libs/jquery.min.js',
             'libs/sweetalert.min.js',
          ], 'public/js/libs.js')
        .styles([
            'libs/sweetalert.css',
        ], 'public/css/libs.css')
        .livereload();

    mix.browserSync({
        proxy: 'localdomain.dev'
    });

});
07 Nov
2 years ago

kayintveen started a new conversation Livereload Not Working With 5.3 Version Of Elixer?

In 5.2 installations i used LiveReload very often and loved it for front-end work. but after i started a new 5.3. project it does not seem to work anymore.

This is my code. The package is pulled in via yarn so should just work right? Maybe i am doing something awfully wrong here

const elixir = require('laravel-elixir');

require('laravel-elixir-vue');
require('laravel-elixir-livereload');

/*
 |--------------------------------------------------------------------------
 | Elixir Asset Management
 |--------------------------------------------------------------------------
 |
 | Elixir provides a clean, fluent API for defining some basic Gulp tasks
 | for your Laravel application. By default, we are compiling the Sass
 | file for our application, as well as publishing vendor resources.
 |
 */

elixir(mix => {
     mix.sass('app.scss')
        .webpack('app.js')
        .scripts([
             'libs/jquery.min.js',
             'libs/sweetalert.min.js',
             'jquery/jquery.tab-navigation.js',
            'jquery/dropit.js',
            'jquery/forms.js',
            './node_modules/chosen-js/chosen.jquery.js',
          ], 'public/js/libs.js')
        .styles([
            'libs/sweetalert.css',
            './node_modules/chosen-js/chosen.css',
        ], 'public/css/libs.css')
        .livereload();

});
05 Nov
2 years ago

kayintveen left a reply on Job Not Passing Model Instantiated In The Constructor To Handle Method

@jaytee sorry that was just a typo in one of my tries. Have tried this. not working :(

04 Nov
2 years ago

kayintveen left a reply on Job Not Passing Model Instantiated In The Constructor To Handle Method

It's pretty simple

namespace App;

use Illuminate\Database\Eloquent\Model;

class Connection extends Model
{
    protected $fillable = ['name','feed_url'];

    public function connection_type()
    {
        return $this->belongsTo(ConnectionType::class);
    }

    public function mappings()
    {
        return $this->hasMany(Mapping::class);
    }
}

kayintveen left a reply on Job Not Passing Model Instantiated In The Constructor To Handle Method

That's a simple model. When I dd in the constructor I do see the content needed.

kayintveen started a new conversation Job Not Passing Model Instantiated In The Constructor To Handle Method

This is super basic, but still i am not seeing something. Getting nuts.

I have a job which i start dispatch(new \App\Jobs\processXmlConnection($connection));

Then i have a qeueuable job which gives null on this DD


use App\Connection;
use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Support\Facades\Storage;

class downloadConnectionFile implements ShouldQueue
{
    use InteractsWithQueue, Queueable, SerializesModels;

    public $xmlconnection;
    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct(Connection $xmlconnection)
    {

        $this->$xmlconnection = $xmlconnection;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        dd($this->$xmlconnection);
    }
}```

kayintveen left a reply on Best Practice: Where To Put Classes That Are Not Models Or Controllers?

All good suggestions. for now i have helpers seperate. and try to bundle as much as possible tight to a responsibility. so i have a csv, xml and excel processor which are all connected to the data connection module. so i have a folder with connections. that made the most sense for now.

kayintveen started a new conversation Best Practice: Where To Put Classes That Are Not Models Or Controllers?

I work with laravel for a quite some time now, but still everytime this question popsup, and i do what i think is best. But working now on a few projects that become pretty large (25+ models, 40+ controllers) I seem to loose grip of the situation a little.

I just conform to the standard structure putting models in the app directory and controllers in the app/http/controllers dir. But often there are other classes not directly a model or controller. What is best practice where to store them? I often bundle them and put the in a app/ folder. or just keep them in app which just doesn't feel right.

Curious how you guys handle this.

19 Oct
2 years ago

kayintveen left a reply on New Mac Install Issues With "laravel New" Composer Issue

uh.. je local on my mac. And as you see in topic start both laravel and composer work fine when i seperately use them.

what i can do is

laravel new test cd test composer install

that works fine. but it should nog be like this

kayintveen left a reply on New Mac Install Issues With "laravel New" Composer Issue

Did exactly what you told me. but again

Crafting application... sh: composer: command not found Application ready! Build something amazing.

and as you can see in my topic start /Users/kveen/.composer/vendor/bin/ was already in my PATH

kayintveen started a new conversation New Mac Install Issues With "laravel New" Composer Issue

Hi all, i have a strange issue on my laravel command. Composer commands works perfectly in my terminal. also laravel new "name" works perfect.

but when i do that command i still get "sh: composer: command not found"

This while it seperately just works perfectly.

I am using iterm with zsh. Type composer gives: composer is an alias for php /usr/local/bin/composer.phar

echo $PATH gives: /Users/kveen/.composer/vendor/bin/:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

so all looks good right?

kayintveen left a reply on Json In Database Over EAV Model In Products Table

@DirkZz Thanks for your response. The reason i added a new topic is purely because due to my investigation in this i can better explain what i mean or where i struggle with. And since i cannot delete old topics and when i change a 2 day old topic i do not get any attention to this thats the reason i added a new one. sorry for that.

Its not really about having a lot of products. but its mainly because there will be a lot of products with varying attributes making this difficult. or at least a potential issue later. maybe i need to create a test case. a faker factory adding thousands of items and doing some speed tests will be the best way probably.

Just wanted to know if anybody has an oppinion on this

18 Oct
2 years ago

kayintveen started a new conversation Json In Database Over EAV Model In Products Table

I need to make a decission on product management for multiple stores. to be exact i need to store around 1million records of products where they al have the basic fields (name, price, description, qty and so on) but can also have multiple attributes. and for one store this can be X Y Z for the other it can be A B C.

I was thinking for performance sake i add a meta column in json format. or create a attribute table with a product_id relation with the meta in there. Since the +/- 10 fields on the products table need to be indexed. How do you guys look at this performance, flexibility and scaleability wise?

The data both in the products table and the meta table will be morphed in to several different product feeds having all different formats. so i think when using a eav model generating a 50k product feed will be hugely painfull for mysql right?

kayintveen started a new conversation Choosing Database Structure For Product Attribute Modification

Hi all,

I'm making a product management application for e-commerce solutions. its really something i struggle with for clients maintaining their product data and distributing it to multiple channels but all channels accept different formats, Excel, Csv, Xml and so on. Some via feed and some via update.

Anyhow i have been playing around with database structures of products trying to map them towards different field. One would call a product name a "name" the other site a "title"

There are 2 approaches im considering.

  1. Some kind of eav kind of structure where all often used fields are in a products table such as: name, short description, description, price, special price, qty, stock status, main image url. A second table would be called attibributes with columns key, value, product_id. or even extending it into attribute type specific columns (integer, varchar, text and so on)

My main concern is that making a feed with field transforms of about 50.000 products would be very heavy. While it is very structured. But each product can have like 10 or 20 attribute rows.

  1. The other kind is more like a json storage of attributes. have the same base product table as above for indexing and such. but having all other variable attributes in a json format either inside the products table or seperate in a attributes table making the processes on the database much easier to consume right.

My concrete question is, do you guys have experience, common pitfalls or warning for me moving forward. Since this is a very important cornerstone piece in my application i am worried to make the wrong decision and therefore the application is not progressing right now. Hoping to get some insight on this. thank for the help!

27 Sep
2 years ago

kayintveen started a new conversation Idea For Channel, Feed And Output Management For Products

I am creating an application for a client which want to manage he's products and attributes in to multiple outputs. Like CSV, Excel, XML feeds and API communication to other partners. All of these outputs are not a problem at all. But the client needs to manage he's dataset, and be able to translate (or map if you will) he's content to the content formats of he's partners. There are 100 ways to do this, but performance is of course an issue, and also frequency. Since product inventory changes new feeds need to be generated every 15 minutes.

Currently my database looks like:

Products

id name description short_description color material manufacturer_id price special_price qty in_stock

Manufacturer

id name

Attributes

id product_id name value (value)

Attributes_Text

id product_id name value (text)

How would you aproach this? Is there a easy function to transform or map an array with eager-loaded content to the format and a format i can store in the database able "channel" for example: Somthing like

Channels

id type name output_name

Channel_type

id name type (partner1, partner2, partner3) output_type (csv, xml, excel)

Channel_template

id channel_id key (name of the field, xml tag, csv column) required value_template_id

Im stuck thinking about this of 2/3 days now, and found multiple solutions, but not all even logic / performance wise the smartest. Very curious if this makes sense at all and if you guys have a good idea how to proceed on this. and what to watch out for. Often output's have like 20.000 or 50.000 product

23 Sep
2 years ago

kayintveen started a new conversation New App. Frontend From Scratch Or Bootstrap

Hi all.

I'm starting on a new app this week and having a hard time to decide between bootstrap or design from scratch.

The main thing that concerns me is speed. Flexibility and expand ability.

The pros are of course probably speed and better structure/overview.

What's your consideration?

02 Aug
2 years ago

kayintveen started a new conversation CSRF Tokens On Almost Similar Domains (https://domain.com Vs Https://test.domain.com)

I have some major CSRF token invalid and Invalid state exceptions on my 2 locations live and test. They have similar domains and i notice my browser has a token with the domain: .domain.com and domain.com

Both have a Session_domain configured in Config/Session.php first has domain.com and the other off course test.domain.com

Anybody got experience.

06 Jul
2 years ago

kayintveen left a reply on Validator Keeps Giving Error, Why Dd() Shows Value

Hi @snapey i proceeded with other functionality to look at it with a fresh mind. and left it there. still issue is not resolved and now found another case of this situation

Form:

                <div class="radiohalf"><input type="radio" name="relationship_status" value="0" v-model="relationship_status" v-model="formInputs.relationship_status"> Currently</div>
                <div class="radiohalf"><input type="radio" name="relationship_status" value="1" v-model="relationship_status"  v-model="formInputs.relationship_status"> Previously</div>

When i dd($request->input('relationship_status')); it shows either "0" and "1" (tried testing with both values"

$this->validate($request, [
    'feedback' => 'required|min:150',
     'relationship_status' => 'required:boolean',
         'relationship_id' => 'required',
        ]);

result

{"relationship_status":["The relationship status field is required."],"relationship_id":["The relationship id field is required."]}

Again tried renaming, debugging, other values like now feedback does work either when empty it gives error or without it shows nothing. Driving me insane!

26 Jun
2 years ago

kayintveen left a reply on Refactoring A User Relation Where Command On HasMany Relationship

No. a user = a person that can login. and Account is like a facbook page. 1 user can have multiple pages (in this case accounts)

kayintveen left a reply on Refactoring A User Relation Where Command On HasMany Relationship

Yes your right @ruffles 1 account can have one account type. but there can be multiple of one account type thus there will be and belongsToOne on the accounts. A user can have multiple accounts thus multiple account types.

What i need to do is select all users that have a account type of freelancer.. So they need to have one account that has at lease a specific account type. So thats why i was thinking about something like

User::has('accounts')->where('account_type_id',1)->get();

Where i only select users that have at lease 1 account (has('accounts')). and the account_type_id is a column on the accounts model. But this does not work.

kayintveen left a reply on Refactoring A User Relation Where Command On HasMany Relationship

Belongs to many is used, im thinking... this actually should be belongs to one. but doest not makes to much of a differance right @ruffles

kayintveen started a new conversation Refactoring A User Relation Where Command On HasMany Relationship

I made a un-flexible code that brought me to a solution but it hurts. Its not flexible, and im absolutely sure there is a better solution.

I have a USER model that can be related to MANY accounts. A Account can have a Account_type_id connected to a ACCOUNT_TYPE model.

So i wanted something like

User::has('accounts')->where('account_type_id', 1)->paginate(30); 

But that does not work. so i added a function to User.php

public function freelancerAccounts()
    {
        return $this->belongsToMany('App\Account')->where('account_type_id', 1);
    }

but for all types of relations i now need to add these functions (currently 3 account types, but i can imagen this will grow in time. and we get a fourth, fifth account type and so on.

Whats the correct way here?

15 Jun
2 years ago

kayintveen left a reply on Validator Keeps Giving Error, Why Dd() Shows Value

Here is a example

array:15 [▼
  "_token" => "ipPGO7RGrbVf8GoHRwxIZW8GBKeyrfwKm9w5rQhy"
  "name" => "sadfasdfdsa"
  "description" => "fasdfdsa"
  "company_website" => "http://www.google.com"
  "address" => "dsafasf 22"
  "postal_code" => "1111 AA"
  "city" => "sdfasf"
  "state" => "sdsfasdfadsf"
  "country" => "BE"
  "phone" => "000000000"
  "industry" => array:1 [▼
    0 => "7"
  ]
  "linkedin" => ""
  "facebook" => ""
  "twitter" => ""
  "glassdoor" => ""
]
14 Jun
2 years ago

kayintveen left a reply on Validator Keeps Giving Error, Why Dd() Shows Value

I was almost thinking i was but no..

<select  class="select" name="country" id="" placeholder="Select your country" style="width:330px;" v-model="formInputs.country" v-show="!formInputs.country">

kayintveen left a reply on Validator Keeps Giving Error, Why Dd() Shows Value

Because i get the message "the field country is required"

kayintveen started a new conversation Validator Keeps Giving Error, Why Dd() Shows Value

Hi all,

I know have a few situations where the following occurs. I have a validator when i do $request->all(). i get all values including the "country" field. but every time it gives me a validation error.

$this->validate($request, [
            'company_website' => 'required|max:255',
            'address' => 'required|max:255',
            'postal_code' => 'required|max:7',
            'phone' => 'required|max:255',
            'name' => 'required|max:255',
            'description' => 'required',
            'city' => 'required',
            'state' => 'required',
            'country' => 'required',
        ]);

Why is this happening? Such a validation just looks if $request->input('country') has a value right?

08 Jun
2 years ago

kayintveen left a reply on Auth Scaffold Made Changes How To Move It Out Vendor Folder

Just made one huge AuthController god monster object. Going to refactor later, but works like a charm!

kayintveen started a new conversation Auth Scaffold Made Changes How To Move It Out Vendor Folder

Hi all,

I used artisan make:auth for the authentication scaffold. But i needed to make changes to multiple traits. such as. RegistersUsers, Resetspassword and authenticatesuser. But of course when i push this live via Envoyer, the vendor folder will be downloaded and or updated and my changes are gone. How can i move them back to my app folder for example?

kayintveen left a reply on Auth::attempt Doesn't Work On Localhost

I just has something familiar. Try the following things.

  1. Clean all your caches / cookies (or try chrome incognito mode)
  2. Are your routes inside web middleware? Route::group(['middleware' => 'web'], function () { });

kayintveen started a new conversation After Installing Larave/socialite Auth::user() Not Persisting

Today i implemented the Socialite plugin. But after installing my sessions even from the login form before are not persisting anymore. . Its all inside the web middleware. And before configuring this it all worked fine.. How can a socialAuthController mess this up?

To be honest i included the socialite already yesterday. but just did not configure the controller yet. and on that version it still works. so only things that are different are the controller. 2 new routes

Route::get('/social/auth/redirect/{provider}', '[email protected]');
Route::get('/social/auth/{provider}', '[email protected]');
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\SocialAccountService;
use Socialite;
use Laravel\Socialite\Contracts\User as ProviderUser;
use App\SocialAccount;
use App\User;
use Auth;

class SocialAuthController extends Controller
{

    /**
     * Generate a redirect command towards the "Driver"
     * In our case facebook/linkedin/google
     * @param $driver
     * @return mixed
     */
    public function redirectToProvider($driver)
    {
        return Socialite::driver($driver)->redirect();
    }

    /**
     * @param SocialAccountService $service
     * @param $driver (facebook/linkedin/google)
     * @return \Illuminate\Http\RedirectResponse
     */
    public function handleProviderCallback(Request $request, $driver)
    {

        $user = $this->createOrGetUser(Socialite::driver($driver)->user(), $driver);


        Auth::loginUsingId($user->id, true);

        return redirect()->to('/dashboard');
    }



    public function createOrGetUser(ProviderUser $providerUser, $provider)
    {
        $account = SocialAccount::whereProvider($provider)
            ->whereProviderUserId($providerUser->getId())
            ->first();

        if ($account) {
            return $account->user;
        }

        $account = new SocialAccount([
            'provider_user_id' => $providerUser->getId(),
            'provider' => $provider
        ]);

        $user = User::whereEmail($providerUser->getEmail())->first();

        if ( ! $user) {

            $user = $this->createSocialUser([
                'email' => $providerUser->getEmail(),
                'name' => $providerUser->getName(),
                'avatar' => $providerUser->getAvatar(),
            ]);
        }

        $account->user()->associate($user);
        $account->save();

        return $user;

    }


    public function createSocialUser($user)
    {
        // Split first and last names
        $name = explode(" ", $user['name']);

        $user = User::create([
            'email' => $user['email'],
            'first_name' => $name[0],
            'last_name' => $name[1],
            'profile_picture' =>  $user['avatar'],
        ]);

        return $user;
    }

}
06 Jun
2 years ago

kayintveen started a new conversation Cookie In 5.2 Not Persisting?

Hi all,

Im struggling with something basic... cookies. I used to use this all the time in 4.2 where is was simple and straight-forward. but now its a hassle. There is a store function of a object. where i get $request fields, do some alterations and then run the ->save() method and returning $this.

Now i tried

return response($this)->withCookie('review', $this->id, 1440);

But when fetching this in a simple test route with

$request = new Illuminate\Http\Request;
    dd($request->cookie('review'));

ik get "null"

What am i doing wrong?

27 May
2 years ago

kayintveen started a new conversation Structure Application With Admin, Web And Api IO

Hi all,

Just curious of ways and of best practices to implement the following. I'm creating a pretty large application with as mane basis ratings. Objects Ratings ---score types Users

So users rate objects with various dynamic score types. anyhow that structure is pretty clear. but since the API, The Web (users) and a Admin (editors/administrator) are both adding, viewing, and searching content. It seems logic to make one create/store function that can be used by all 3 channels, sometimes having different validations due to the fact of user level, channel it came by and so on.

What makes the most sense, working with just models as IO, Different controllers for API, ADMIN and WEB. Or create a REPO that does the read and write stuff. Or making a FORM OBJECT...

With smaller apps i tend to place all my data read/write stuff in to the model. Validation, redirect and such in the controllers. Not sure if thats a best-practice...