mardi 2 février 2016

Laravel Model create function returns column with null value

In Laravel, When I run the following query, it returns a row with null values.

//Cards.php 


protected $fillable = ['user_id', 'card_id', 'customer_id', 'exp_year', 'exp_month', 'funding', 'brand', 'last4'];

public function createNewCardFromCustomer($user_id, $customer)
    {

        $result = $this->create([
            'user_id' => $user_id,
            'customer_id' => $customer->id,
            'card_id' => $customer['sources']['data'][0]->id,
            'exp_year' => $customer['sources']['data'][0]->exp_year,
            'exp_month' => $customer['sources']['data'][0]->exp_month,
            'funding' => $customer['sources']['data'][0]->funding,
            'brand' => $customer['sources']['data'][0]->brand,
            'last4' => $customer['sources']['data'][0]->last4
        ]);

        return $result;

    }

Even the Model static create method receives the right parameters. And I've taken care of the mass assignment also.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire