vendredi 21 août 2015

Laravel date is not inserting, update in database table

insert and edit the registry but no date columns. |

programming seemingly fine, but failed to get the date field is properly registered.

use UTF8 encoding, locale is (Es)

why? T_T

Table

Schema::create('products', function(Blueprint $table)
    {
        $table->increments('id');
        $table->integer('subclassproduct_id')->unsigned();
        $table->integer('branch_id')->unsigned();
        $table->integer('coin_id')->unsigned();
        $table->string('code', 50);
        $table->string('name', 100);
        $table->string('description', 200);
        $table->text('observation');
        $table->decimal('price', 5,2);
        $table->date('validity_since');
        $table->date('validity_until');
        $table->enum('state', ['Activo', 'Desactivado']); 
        $table->softDeletes();
        $table->timestamps();

        $table->foreign('subclassproduct_id')
            ->references('id')->on('subclasses_products')
            ->onUpdate('CASCADE')
            ->onDelete('CASCADE');  

        $table->foreign('branch_id')
            ->references('id')->on('branches')
            ->onUpdate('CASCADE')
            ->onDelete('CASCADE');

        $table->foreign('coin_id')
            ->references('id')->on('coins')
            ->onUpdate('CASCADE')
            ->onDelete('CASCADE');
    });

Model

this is the model of the table

class Product extends Model {
use  SoftDeletes; // for soft delete

protected $table = 'products';

protected $fillable = [
    'subclassproduct_id', 'branch_id', 'coin_id', 'code' ,'name', 'description', 'observation', 'price', 'validity_since', 'validity_until', 'state'
];

protected $dates = ['deleted_at'];   }

Controller

this is the Controller of the table

    public function update(EditProductRequest $request, $id)
{
    $Product = Product::findOrFail($id);
    $Product->fill($request->all());

    $request->merge(array('validity_since' => Carbon::createFromFormat('d/m/Y', $request->get('validity_since') )->toDateString()));
    $request->merge(array('validity_until' => Carbon::createFromFormat('d/m/Y', $request->get('validity_until') )->toDateString()));



    $Product->save();

    return redirect()->route('administrar.products.index');
}



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1EI6Iga
via IFTTT

Aucun commentaire:

Enregistrer un commentaire