Commit c1a8ccb6 by Francisco Salazar

Detalles de session en interesado

parent d8cd48e0
......@@ -28,3 +28,28 @@ php artisan vendor:publish --provider="Onestartup\CrmForms\CrmFormsServiceProvid
```php
php artisan vendor:publish --tag=config
```
- run command for publish assets
```php
php artisan vendor:publish --tag=public
```
- add next lines to app/Interested.php
```php
public function interested_detail(){
return $this->hasOne('Onestartup\CrmForms\Model\InterestedDetail', 'interested_id');
}
```
- include form in your landing page
```php
@include('crmforms-public::forms.form_base')
```
-include scripts in your landing page
```php
<script src="{{asset('assets/cronometro.js')}}" type="text/javascript" />
```
\ No newline at end of file
......@@ -29,6 +29,10 @@ class CrmFormsServiceProvider extends ServiceProvider
}
$this->publishes([
__DIR__.'/assets' => public_path('assets'),
], 'public');
$this->publishes([
__DIR__.'/views/public' => resource_path('views/vendor/onestartup/crmforms'),
]);
......
var start;
var finish;
jQuery(document).ready(function($) {
start = new Date();
});
jQuery("#landing_form").submit(function($){
finish= new Date();
var tiempo = (+finish - +start) / 1000;
jQuery("#landing_form").append('<input type="hidden" name="session_time" value="'+tiempo+'" />');
});
\ No newline at end of file
......@@ -12,14 +12,40 @@ use App\Notifications\NewInterestd;
use App\Notifications\EmailInvalid;
use App\Interested;
use App\User;
use Jenssegers\Agent\Agent;
use Onestartup\CrmForms\Model\InterestedDetail;
class CrmFormsController extends Controller
{
public function store(RequestInterested $request)
{
$user = User::find(1);
$request;
$agent = new Agent();
$agent->setUserAgent($request->header('User-Agent'));
$browser = $agent->browser();
$browser_version = $agent->version($browser);
$devise = $agent->device();
$platform = $agent->platform();
$platform_version = $agent->version($platform);
$session_time = $request->session_time;
if ($agent->isMobile()){
$devise_type = "Mobil";
}elseif($agent->isTablet()){
$devise_type = "Tablet";
}elseif($agent->isDesktop()){
$devise_type = "Desktop";
}else{
$devise_type = "Otro";
}
$agent->isMobile();
$agent->isTablet();
$user = User::find(1);
if (config('crmforms.validate_email')) { //Se activa la opcion de validar emails por API
......@@ -35,6 +61,20 @@ class CrmFormsController extends Controller
$interested->notify(new WelcomeInterested());
$user->notify(new NewInterestd($interested));
$interested_details = InterestedDetail::firstOrNew(['interested_id' => $interested->id]);
$interested_details->browser = $browser;
$interested_details->browser_version = $browser_version;
$interested_details->devise = $devise;
$interested_details->platform = $platform;
$interested_details->platform_version = $platform_version;
$interested_details->session_time = $session_time;
$interested_details->devise_type = $devise_type;
$interested_details->save();
} else { // Si el correo no es valido
$user->notify(new EmailInvalid($request->all()));
......@@ -53,6 +93,19 @@ class CrmFormsController extends Controller
$interested = Interested::create($request->all());
$interested->notify(new WelcomeInterested());
$user->notify(new NewInterestd($interested));
$interested_details = InterestedDetail::firstOrNew(['interested_id' => $interested->id]);
$interested_details->browser = $browser;
$interested_details->browser_version = $browser_version;
$interested_details->devise = $devise;
$interested_details->plataform = $platform;
$interested_details->plataform_version = $platform_version;
$interested_details->session_time = $session_time;
$interested_details->devise_type = $devise_type;
$interested_details->save();
}
......
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateInterestedDetailsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('interested_details', function (Blueprint $table) {
$table->increments('id');
$table->integer('interested_id')->unsigned();
$table->string('browser')->nullable();
$table->string('browser_version')->nullable();
$table->string('devise')->nullable();
$table->string('devise_type')->nullable();
$table->string('platform')->nullable();
$table->string('platform_version')->nullable();
$table->double('session_time', 8, 2)->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('interested_details');
}
}
<?php
namespace Onestartup\CrmForms\Model;
use Illuminate\Database\Eloquent\Model;
class InterestedDetail extends Model{
protected $table = 'interested_details';
protected $fillable = ["interested_id", "browser", "browser_version", "devise", "platform", "platform_version","session_time"];
public function interested(){
return $this->belongsTo('App/Interested', 'interested_id');
}
}
\ No newline at end of file
......@@ -2,7 +2,7 @@
@include('partials.messages_partial')
{{-- No remover --}}
{!! Form::open(['route'=> ['crmforms.store'],"method"=>"POST"]) !!}
{!! Form::open(['route'=> ['crmforms.store'],"method"=>"POST", "id"=>"landing_form"]) !!}
{!! Form::hidden('landing', (Request::path() != '/' ? Request::path() : 'inicio') ) !!}
@if(isset($_GET["_rdr"]))
......@@ -11,7 +11,7 @@
{!! Form::hidden('origin', 'ninguno') !!}
@endif
{{-- *********** --}}
dsasd
<div class="row">
<div class="col-md-6">
{!! Form::label('name', 'Nombre', ['class'=>'']) !!}
......@@ -40,4 +40,4 @@
{{-- No remover --}}
{!! Form::close() !!}
{{-- **********] --}}
\ No newline at end of file
{{-- **********] --}}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment