jeudi 5 juillet 2018

Increase the value of count in laravel 5.6

I have two tables rta_list and rta_reg_company. I have a column count in rta_list table.

 Schema::create('rta_list', function (Blueprint $table) {
    $table->increments('rta_id');
    $table->string('rta_name');
    $table->string('rta_address');
    $table->string('rta_phone');
    $table->string('rta_email')->unique();
    $table->integer('count'); 
    $table->timestamps();
});

 Schema::create('rta_reg_company', function (Blueprint $table) {
    $table->increments('company_id');
    $table->integer('rta_id')->unsigned();
    $table->foreign('rta_id')
        ->references('id')
        ->on('rta_lists')
        ->onDelete('cascade');
    $table->string('company_name');
    $table->string('company_isin');
    $table->string('company_script');
    $table->string('company_address');
    $table->string('company_phone');
    $table->string('company_email');
    $table->timestamps();
});

I want to increase the value of count of rta_list table by rta_id when I add new RTA Registered Company. For eg: if i add one company then, The value must be added in rta_reg_company table and count must be 1 in count column in rta_list table.

Also also how to show the count value by rta_id in view.. Help Needed.....



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire