in your controller, you can do it.
$newRow = new YourModelName;
$newRow->column1 = $requesst->value1;
$newRow->column2 = $requesst->value2;
$newRow->column3 = $requesst->value3;
$newRow->column4 = $requesst->value4;
$newRow->save();
read more at laravel documentation: https://laravel.com/docs/5.2/eloquent#inserting-and-updating-models
jcodesdotme said:
in your controller, you can do it.
$newRow = new YourModelName; $newRow->column1 = $requesst->value1; $newRow->column2 = $requesst->value2; $newRow->column3 = $requesst->value3; $newRow->column4 = $requesst->value4; $newRow->save();
read more at laravel documentation: https://laravel.com/docs/5.2/eloquent#inserting-and-updating-models
these is not what im trying to do
Well,you could use the data coming from the request and do a raw DB query. To see more aboute raw query, check this link https://laravel.com/docs/5.2/queries
An than, perform an alter table on the table you would like. Search for add column table mysql and you will see how to do it.
<?php
namespace App\Http\Controllers;
use Schema;
use Illuminate\Database\Schema\Blueprint;
class DatabaseTableController extends Controller
{
public function addColumn($sTable, $sColumn)
{
Schema::table($sTable, function(Blueprint $table) use ($sColumn, &$fluent)
{
$fluent = $table->string($sColumn);
});
return response()->json($fluent);
}
}
Route:
Route::get('table_add_column/{t}/{c}', 'DatabaseTableController@addColumn');
So URL like this: http://example.com/table_add_column/users/address2 produces:
{"type":"string","name":"address2","length":255}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community