In my group page i am creating new group ID, when i create the groupID automatically that time need to store into database, column creationTime. I am using laravel 5.2 framework for building my application. How can i take that creation time and store the same to the database when inserting groupID to the table. my GroupController.php
public function groupInsert()
{
$postGeozone=Input::all();
//insert data into mysql table
$account = Account::select('accountID')->get();
foreach ($account as $acc) {
$abc = $acc->accountID;
}
$data = array(
"accountID" => $abc,
"groupID"=> $postGeozone['groupID']
);
//$data=array('groupID'=> $postGeozone['groupID']);
$ck=0;
$ck=DB::table('devicegroup')->insert($data);
$groups = DB::table('devicegroup')->simplePaginate(5);
return view('group.groupAdmin')->with('groups',$groups);
}
groupAdmin.blade.php is
@extends('app')
@section('content')
<div class="templatemo-content-wrapper">
<div class="templatemo-content">
<ol class="breadcrumb">
<li><a href="{{ url("/") }}"><font color="green">Home</font></a></li>
<li class="active">Group information</li>
</ol>
<h1>View/Edit Group information</h1>
<p></p>
<div class="row">
<div class="col-md-12">
<div class="table-responsive">
<table id="example" class="table table-striped table-hover table-bordered">
<h3>Select a Group :</h3>
<thead>
<tr>
<th>Group ID</th>
<th>Group Name</th>
<th>Vehicle Count</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach($groups as $grp)
<tr>
<td>{{ $grp->groupID }}</td>
<td>{{ $grp->description }}</td>
<td></td>
<td>
<div class="btn-group">
<button type="button" class="btn btn-info">Action</button>
<button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu" role="menu">
{{--@if ($nam->isActive == 'Yes')--}}
<li data-toggle="modal" data-target="#acceptModal" data-bookingid="{{ $grp->groupID }}"><a href="{{ url('/group/edit/'.$grp->groupID) }}">View/ Edit</a>
</li>
{{--@endif--}}
<li><a href="{{ url('/group/delete/'.$grp->groupID)}}">Delete</a></li>
</ul>
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
{{$groups->links()}}
</div>
</div>
</div>
</div>
</div>
</br>
{{--Creating new group--}}
{{--------------------------------------------------}}
<h4>Create a new Group</h4>
<form role="form" method="POST" action="{{ url('groupAdmin') }}">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<div class="row">
<div class="col-md-6 margin-bottom-15">
<input type="text" class="form-control" name="groupID" value="{{ old('groupID') }}" placeholder="Enter Group ID">
</div>
<div class="row templatemo-form-buttons">
<div class="submit-button">
<button type="submit" class="btn btn-primary">New</button>
</div>
</div>
</div>
</form>
<script type="text/javascript">
$(document).ready(function() {
$('#example').dataTable();
} );
</script>
@endsection
routes.php
Route::any('groupAdmin', 'GroupController@getIndex');
Route::post('groupAdmin', 'GroupController@groupInsert');
model Group.php
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Group extends Model
{
protected $table = 'devicegroup';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'groupID', 'description',
];
protected $hidden = [
'password', 'remember_token',
];
}
Can anyone please tell how to do , replies are appreciable.