esorone

Experience

4,160

1 Best Reply Awards

  • Member Since 2 Years Ago
  • 26 Lessons Completed
  • 0 Favorites

19th September, 2018

esorone left a reply on Save Toggle Data Into Db • 6 hours ago

Hey Both,

I just made an identical form, based on copy / past of the original form. I tested it with the Formbuilder as well as HTML. I tested it one by one, so add a new field, test it, add another one, etc.

I did not find any errors in my new form and I used the same controller.

So there is something strange in my code and the form library..

I wish I could point it out, but I can't, but my problem is solved.

Thanks again for helping me and the thorough checks of my code.

Kr

esorone left a reply on Save Toggle Data Into Db • 8 hours ago

Hey Both,

I just started a new view (result), (complete new setup) and this works perfectly fine. So I have made an error somewhere. Therefor I will build this page from scratch.

For other members, the following works, AND I will show my errors later on.

VIEW

<div class="span4">
    <div class="widget-box">
        <div class="widget-title">
            <span class="icon">
                <i class="icon-edit">
                </i>
            </span>
            <h5>Feedback</h5>
        </div>
        <div class="widget-content">
            <div class="control-group">
            {{ Form::open(array('route' => 'result.store', 'class' => 'form-horizontal', 'id'=>'tijd')) }} @csrf

            <input type="checkbox" name="kennisbankboolean" value="1">

             {{ Form::submit('creer contact', array('class' => 'btn btn-success btn-lg btn-block')) }}  {{ Form::close() }}
        
        </div>
        </div>
    </div>
</div>

Controller

  /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        $result = new Result();
        $result->name = 'testName';
        $result->kennisbankboolean = (int) $request->has('kennisbankboolean');

        if ($result->save()){
            return redirect()->route('result.index')
            ->with('flash_message_success', 'Contact,
             ' . $result->name . ' Geregistreerd');
        }else {
            return redirect()->route('result.index')
            ->with('flash_message_error', 'Contact,
             ' . $result->name . ' NIET Geregistreerd');
        }
    }

Unchecked will store a 0, and checked will store a 1

esorone left a reply on Save Toggle Data Into Db • 9 hours ago

Hello,

Really sharp.. I check this x times, but did not notice this one.

So I removed it..

BUT, it did not solve my problem :-(.

I just checked the checkbox both Times (checked / unchecked), both ways stores a zero in the database.

A dd($request->all()); still produces:

array:10 [▼
  "_token" => "ar52eQBH5LXFR49xO1S"
  "title" => "sdfasdf"
  "channel" => "2"
  "department" => "5"
  "hoofdcategory" => "2"
  "subcategory" => "2"
  "user_id" => "1"
  "starttijd" => "2018-09-19 19:03:18"
  "body" => "sadfasdfasdfasdf"
  "feedbacktxt" => "00"
]

esorone left a reply on Save Toggle Data Into Db • 10 hours ago

Hello Both,

Sorry for the delay, (Busy at work).

First of all, really appreciate you help on the topic..

@ultimateBusiness I tried your solution, but it dit not solve my issue

Underneath my view.


@extends('layouts.adminlayouts.admin_design') @section('content')@can('Contacten Registreren')
<link href="https://gitcdn.github.io/bootstrap-toggle/2.2.2/css/bootstrap-toggle.min.css" rel="stylesheet">
<script src="https://gitcdn.github.io/bootstrap-toggle/2.2.2/js/bootstrap-toggle.min.js"></script>

<div id="content">

    <div id="content-header">
        <div id="breadcrumb">
            <a href="index.html" title="Go to Home" class="tip-bottom">
                <i class="icon-home"></i> Home</a>
            <a href="{{url('/posts/')}}">Registraties</a>
            <a href="{{ route('posts.create') }}" class="current">Registratie aanmaken</a>
        </div>
        <h1>Registreer een klantcontact</h1>
    </div>
    @if(Session::has('flash_message_success'))
    <button data-dismiss="alert" type="button" class="close" <i class="icon-sitemap">
        </i>
    </button>
    <div class="alert alert-success">
        <em> {!! session('flash_message_success') !!}</em>
    </div>
    @endif @if(Session::has('flash_message_error'))

    <button data-dismiss="alert" type="button" class="close" <i class="icon-sitemap">
        </i>
    </button>
    <div class="alert alert-danger">
        <em> {!! session('flash_message_error') !!}
                @foreach ($errors->all() as $error)
                  {!! $errors->first() !!}
                @endforeach
        </em>
    </div>
    @endif
            @if(Session::has('errors'))
    <button data-dismiss="alert" type="button" class="close" <i class="icon-sitemap">
        </i>
    </button>

    <div class="alert alert-danger">
        <em> 
    @foreach ($errors->all() as $error)
       {!! $errors->first() !!}
    @endforeach
        </em>
    </div>
@endif


    <div class="container-fluid">
        <hr>
        <div class="row-fluid">
            <div class="span8">
                <div class="widget-box">
                    <div class="widget-title">
                        <span class="icon">
                            <i class="icon-lemon">
                            </i>
                        </span>
                        <h5>Registreer klantcontact</h5>
                    </div>
                    <div class="widget-content nopadding">
                        {{ Form::open(array('route' => 'posts.store', 'class' => 'form-horizontal', 'id'=>'tijd')) }} @csrf
                        <div class="control-group">
                            <label class="control-label">{{ Form::label('title', 'Title') }}</label>
                            <div class="controls">
                                {{ Form::text('title', null, array('class' => 'span11')) }}
                            </div>
                        </div>
                        {{ Form::open(array('url'=>'','files'=>true)) }}
                        <div class="control-group">
                        <label class="control-label">Kanaal</label>
                            <div class="controls">
                                <select name="channel" id="channel">
                                    @foreach($channels as $channel)
                                    <option value="{{$channel->id}}">{{$channel->name}}</option>
                                    @endforeach
                                </select>
                            </div>
                        <label class="control-label">Afdeling</label>
                            <div class="controls">
                                <select name="department" id="department">
                                    @foreach($departments as $department)
                                    <option value="{{$department->id}}">{{$department->name}}</option>
                                    @endforeach
                                </select>
                            </div>
                            <label class="control-label">Hoofd Categorie</label>
                            <div class="controls">
                                <select name="hoofdcategory" id="hoofdcategory">
                                <option selected disabled>Selecteer een hoofdcategorie</option>
                                    @foreach($categories as $category)
                                    <option value="{{$category->id}}">{{$category->name}}</option>    
                                    @endforeach
                                </select>
                            </div>
                            <label class="control-label">Sub Categorie</label>
                            <div class="controls">
                                <select class="form-control" name="subcategory" id="subcategory">
                                <option selected="selected"></option> </select>
                                    <input type="hidden" name="user_id" id="user_id" value="{{Auth::user()->id}}">
                            </div>
                            <div class="control-group">
                            <label class="control-label">Tijdstip: </label>
                            <div class="controls">
                                    <input type="text" name="starttijd" id="starttijd" class="span11" value="{{ \Carbon\Carbon::now() }} " />
                            </div>
                        </div>
                                     </div>
                        <div class="control-group">
                            <label class="control-label"> {{ Form::label('body', 'Body') }}</label>
                            <div class="controls">
                                {{ Form::textarea('body', null, array('class' => 'span11')) }}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="span4">
            <div class="widget-box">
            <div class="widget-title">
                        <span class="icon">
                            <i class="icon-edit">
                            </i>
                        </span>
                        <h5>Feedback</h5>
                    </div>
                    <div class="widget-content">
                    <div class="control-group">
                            <label class="control-label">{{ Form::label('kennisbankboolean', 'Beschikbaar in Kennisbank?') }}</label>
                            <div class="controls">         
                             <input type="checkbox" name="kennisbankboolean" value="1">
                            <BR>
                               <hr>
                               <label class="control-label">{{ Form::label('title', 'Wil je feedback geven?') }}</label>
                                {{ Form::checkbox('feedbackboolean', 1) }}Ja
                                <hr>
                               <label class="control-label"> {{ Form::label('Feedbacktxt', 'Feedback') }}</label>
                                <div class="controls">
                                {{ Form::textarea('feedbacktxt', null, array('class' => 'span11')) }}
                                <hr>
                            </div>
                        </div>
                    </div>
            </div>                       {{ Form::submit('creer contact', array('class' => 'btn btn-success btn-lg btn-block')) }}  {{ Form::close() }}
          </div>
        </div>
    </div>
</div>
@endcan
    <script>
    $(document).ready(function () {
        $("#hoofdcategory").on('change', function (e) {
            console.log(e);
            var cat_id = e.target.value;

            $.get('/admin/ajax-subcat/' + cat_id, function (data) {
                //success data
                // console.log(data);
                $('#subcategory').empty();
                $.each(data, function (index, subcatObj) {
                    $('#subcategory').append('<option value ="' + subcatObj.id + '">' +
                        subcatObj.name + '</option>');

                });
            });
        });
    });
</script>

@endsection

My Controller:

 /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //Validating title and body field
       $this->validate($request, [
            'title' => 'required|max:100',
            'channel' => 'required',
            'department' => 'required',
            'hoofdcategory' => 'required',
            'subcategory' => 'required',
            'body' => 'required',
            'user_id' => 'required',
            'starttijd' => 'required',
        ]);


        $startTime = Carbon::parse($request->starttijd);
        $finishTime = Carbon::now();
        $totalDuration = $finishTime->diffinSeconds($startTime);
        $seconden = $request->starttijd;
        $post = new Post();
        $post->title = $request->title;
        $post->body = $request->body;
        $post->channel_id = $request->channel;
        $post->department_id = $request->department;
        $post->hoofdcategories_id = $request->hoofdcategory;
        $post->subcategories_id = $request->subcategory;
        $post->kennisbankboolean = (int) $request->has('kennisbankboolean');
        $post->feedbackboolean = (int) $request->has('feedbackboolean');
        $post->feedbacktxt = $request->feedbacktxt;
        $post->user_id = $request->user_id;
        $post->seconds = $totalDuration;

        // dd($request->all());
        if ($post->save()){
            return redirect()->route('posts.index')
            ->with('flash_message_success', 'Contact,
             ' . $post->title . ' Geregistreerd');
        }else {
            return redirect()->route('posts.index')
            ->with('flash_message_error', 'Contact,
             ' . $post->title . ' NIET Geregistreerd');
        }
        

    }

JS script route:

Route::get('admin/ajax-subcat/{cat_id}', '[email protected]')->name('ajax');

So the CascadeController

<?php

namespace App\Http\Controllers;

use App\Subcategory;

/**
 * 
 */
class CascadeController extends Controller
{
    public function ajax($cat_id)
    {
        $cat_id = $cat_id;
        $subcategory = Subcategory::where('category_id', '=', $cat_id)->get();
        return response()->json($subcategory);
    }
}

18th September, 2018

esorone left a reply on Save Toggle Data Into Db • 1 day ago

Hey Snapey,

I did not see any value during the DD.. $post->kennisbankboolean = (int) $request->has('kennisbankboolean'); $post->feedbackboolean = (int) $request->has('feedbackboolean');

Did not check anything.

array:10 [▼
  "_token" => "iYzAPfAzpyXHsAZVHih2Pn63axcJ"
  "title" => "fasdfasdf"
  "channel" => "1"
  "department" => "2"
  "hoofdcategory" => "1"
  "subcategory" => "3"
  "user_id" => "1"
  "starttijd" => "2018-09-18 19:18:29"
  "body" => "fasdfasdfasd"
  "feedbacktxt" => "00"
]

Checked both checkboxes.

array:10 [▼
  "_token" => "iYzAPfAzpyXHsAZVHih2Pn63axcJiFZ"
  "title" => "fasdfasdf"
  "channel" => "1"
  "department" => "2"
  "hoofdcategory" => "1"
  "subcategory" => "3"
  "user_id" => "1"
  "starttijd" => "2018-09-18 19:19:49"
  "body" => "fasdfasdfasd"
  "feedbacktxt" => "11"
]

I'm still able to store a 0 value.. the other value is null... Im really confused.

17th September, 2018

esorone left a reply on Save Toggle Data Into Db • 2 days ago

What I'm going to do, is create a new page tomorrow, Fresh start, and lets see if I'm able to store the proper values.

Keep you guys posted.

esorone left a reply on Save Toggle Data Into Db • 2 days ago

In the same form I have a "dynamic" cascading pulldown menu. Category and subcategory. I just removed the script, but same result :-(

This one is really giving me an headache

esorone left a reply on Save Toggle Data Into Db • 2 days ago

Hey Cronix,

I know, the behaviour is at least 30 years, but I cannot solve this one, and my current technique is trail and error.. And read numerous topics online and just try and give some extra input.

You will not believe it, but your solution provides a 0, same as before.

I updated mine:

view
<input type="checkbox" name="kennisbankboolean" value="1">

controller
    $post->kennisbankboolean = (int) $request->has('kennisbankboolean');

I even added your field to my database, contoller, etc

view

<input type="checkbox" name="testcb" value="1">

Controller:
        $post->testcb = (int) $request->has('testcb');

And again only a Zero :-(

What am I missing here........

[Quote] Try a simple example. Put this on your form (don't use that dumb form library) [Unquote]

Done

esorone left a reply on Save Toggle Data Into Db • 2 days ago

Update.

I just checked the value via js.

<script>
    $(document).ready(function () {
        $('input[name="kennisbankboolean"]').change(function(){ 
        console.log($('.controls').find("input:checkbox[name ='kennisbankboolean']:checked").val());
});
});
</script>

If I check the checkbox, the value is shown as 0 If I uncheck it, i receive "undefined"..

I tried to update the $post with;

      $post->kennisbankboolean = (int) $request->has('kennisbankboolean')? 1 : 0;

Or the other way around, but still no luck.

I would expect a 1 when checked and a 0 unchecked.

esorone left a reply on Save Toggle Data Into Db • 2 days ago

Hey Both,

Yes, my column is called "kennisbankboolean" and "feedbackboolean". And there is a 0 value stored in the db. I just copy / past the name from sequel Pro to my code editor (just to make sure)

The feedbackboolean service an different purpose. If this one is checked, the feedback is related to a knowledge base. The Feedback field is generic.

I hope you guys got some ideas left. Or maybe a different approach?

15th September, 2018

esorone left a reply on Save Toggle Data Into Db • 4 days ago

Hey Cronix,

As always, thanks again. I'm able to store a value, but..

Still one question left. If I check it or don't check it, the value is the same "0" in the database.

Any ideas left?

14th September, 2018

esorone started a new conversation Save Toggle Data Into Db • 5 days ago

Goodnight,

I'm struggling with saving my toggle data into the database.

I tried numerous options, but no did work

current try. In my view:

                               {{ Form::checkbox('feedbackboolean', 1) }}Ja
                               {{ Form::checkbox('feedbackboolean', 0) }}Nee

Seconds Try: Just a toggle button

<input type="checkbox" name="feedbackboolean" checked data-toggle="toggle" data-on="1" data-off="0">

In my controller:

        $post->feedbackboolean = $request->get('feedbackboolean');

or 

      $post->kennisbankboolean = $request->get('kennisbankboolean', 0);

Or

        $post->feedbackboolean = $request->feedbackboolean;

But unfortunately they did not work. The samples above , are just a sample which I all found online. So somewhere Im misinterpret the solution

The rest of the post form is stored in the database and works as it should be.

What am I missing here.

As always, thanks in advanced.

31st August, 2018

esorone left a reply on Wrong Pulldown Value Populated On Edit • 2 weeks ago

Hello all,

Indeed it was the $post->channel part and I like the clean look of Snapey,

Thx for your help again.

30th August, 2018

esorone started a new conversation Wrong Pulldown Value Populated On Edit • 2 weeks ago

Goodafternoon,

I have a small issue, which I cannot solve by myself.

I have a post form, including a dynamic pulldown. This works really well, (cascading based on the first option) If I check the entire post lists , all the input fields have the right values.

E.g. channel = whatsapp, category = school, sub-category = openinghours.

So all good.

But when I try to edit the post, (post/1/edit) I receive other values. And these are different than the values which are stored in the DB. The DB values are the same as mention above.

E.g. channel = voice, category = parkinglot, sub-category = rate.

At this stage I can change it again and it will be stored. But how can I make sure that the right values of the pull down menu are populated with the right values in the first try.

My blade:

                                <select name="channel" id="channel">
                                    @foreach($channels as $channel)
                                    <option value="{{$channel->id}}">{{$channel->name}}</option>
                                    @endforeach
                                </select>

I tried to use the old() method as well, but this did not solve the problem.

<select name="channel" id="channel">
        @foreach($channels as $channel)
              <option value="{{$channel->id}}"{{(old('channel') == $channel->id)?'selected':''}}>       {{$channel->name}}</option>
             @endforeach 
</select>

Ofcourse the reason is that i use the foreach, but I still need the possibility to change these values on edit.

So, Show the original values, but still able to use the foreach.

Thx again all.

28th August, 2018

esorone left a reply on Create Vhost Apche2 • 3 weeks ago

FYI, You still can use php artisan serve in your document route.

Kr

12th August, 2018

esorone left a reply on Mysql Throws Multiple Connection Errors [2002] & [2006] • 1 month ago

What value do you use at wait_timeout: The wait_timeout variable represents the amount of time that MySQL will wait before killing an idle connection

esorone left a reply on My Create This Code But Its Not Looking Good • 1 month ago

I missed a “ after sharing_personal_experiences.

esorone left a reply on My Create This Code But Its Not Looking Good • 1 month ago

Maybe something like this:


<form action="/xxxxxx“>
  <select style="width:200px;" name="Providing">
    <option value="providing_next_steps">providing next steps</option>
<option value="providing_guidance">providing guidance </option>
<option value="sharing_personal_experiences>Sharing personal experiences</option>
  </select>
  <br><br>
  <input type="submit">
</form>

5th August, 2018

esorone left a reply on Display Blade Data As A List, Tile Or Simple Table • 1 month ago

Hello Jenya,

The default PHP:


<?php echo $grid->render(); ?>

# Example below will also work as Grid class implements __toString method.
# Note that you can't forward Exceptions through __toString method on account of PHP limitations.
# Therefore you can preliminarily render grid in debug reasons and then pass resutls to view.
<?php echo $grid; ?>

But you should be able to use a syntax in Blade. I checked the documentation as well and this is confirmed by the developer

{!! $grid !!}

The @if , @else is a.f.a.i.k independent of the package. So you should be good to go

Kr

4th August, 2018

esorone left a reply on Pass Controller Array To Javascript (ChartJs) • 1 month ago

I was so close, and worked already two days on this item.. And in total I had to add 7 characters and remove two.

Thanks lostdreamer_nl

esorone left a reply on Display Blade Data As A List, Tile Or Simple Table • 1 month ago

Hello,

I know https://github.com/Nayjest/Grids is working with Blade templating.

Just check it out.

esorone left a reply on Pass Controller Array To Javascript (ChartJs) • 1 month ago

Hey lostdreamer_nl,

Unfortunately this results in an error. "Call to a member function keys()"

This occurs if I change my view from

var month = {!! json_encode($month) !!};

to:

var month = {!! json_encode($month->keys()) !!};

I tried to make a change in the controller as well.

            ->with('month', json_encode($month->keys()));

vs

       ->with('month', [$month]);

with the view

var month = {!! json_encode($month) !!};

resulted in :


   var month = "[\"May\",\"Jun\",\"Jul\",\"Apr\"]";

So I think we are nearly there, and I hope you have an other idea.

Kr

esorone left a reply on Count All Current Users In Database • 1 month ago

Hello,

I just would like to make it a little bit easier.

You can retrieve the count via your model. Just use

       $users = User::count();

in your controller and parse this value to your view.

Kr

esorone started a new conversation Pass Controller Array To Javascript (ChartJs) • 1 month ago

Hello All,

My project is coming to an end, thanks too lots of you. But I'm still running to some issues. I guess I'm on the right track, but I cannot find the right solution. (lack of knowledge, or misunderstanding)

The only thing i need to have is the created_at, converted to a month (I manage this) and than parse this value towards a javascript var.

I got a controller:

  public function totalAHT()
    {
        $AHT = Post::select(DB::raw("SUM(seconds) as seconds"))
            ->orderBy("created_at")
            ->groupBy(DB::raw("month(created_at)"))
            ->get()->toArray();
        $AHT = array_column($AHT, 'seconds');

        $month= Post::all('created_at')
            ->groupBy(
                function ($val) {
                    return Carbon::parse($val->created_at)->format('M');
                }
            );

        // dd($month);

        return view('charts.totalahtpermaand')
            ->with('AHT', json_encode($AHT, JSON_NUMERIC_CHECK))
            ->with('month', [$month]);
    }

The output of dd($month). So the months are being populated.

Collection {#883 ▼
  #items: array:4 [▼
    "May" => Collection {#834 ▶}
    "Jun" => Collection {#845 ▶}
    "Jul" => Collection {#861 ▶}
    "Apr" => Collection {#882 ▶}
  ]
}

So the groupBy Months works, but it is the complete collection.

If I use in my view:

 <script> var month =['Jan','Feb','Mrt','April'] </script>

The Charts works fluently, but of course I would like to have it dynamically

I have tried numerous possibilities, but I'm not able to get the labeling right.

   var month = {!! json_encode($month) !!};

outputs:

var month = [{"May":[{"created_at":"2018-05-03 20:09:27"},{"created_at":"2018-05-04 20:14:44"}],"Jun":[{"created_at":"2018-06-18 18:59:11"},{"created_at":"2018-06-18 19:37:09"},{"created_at":"2018-06-18 19:38:14"}],"Jul":[{"created_at":"2018-07-24 19:46:33"},{"created_at":"2018-07-24 21:10:03"},{"created_at":"2018-07-24 21:12:44"},{"created_at":"2018-07-24 21:19:15"}],"Apr":[{"created_at":"2018-04-24 21:19:15"}]}];

instead of Apr,May, Jun, Jul, 

    var month = <?php echo $month; ?>

outputs the same as above.

I tried a Foreach loop as well, but no luck, Even changing the controller did not do the trick

    return view('charts.totalahtpermaand')
        ->with('AHT', json_encode($AHT, JSON_NUMERIC_CHECK))
        ->with('month', json_encode($AHT, JSON_NUMERIC_CHECK))

So what do I do wrong, or I do not understand.

Thanks again.

3rd August, 2018

esorone left a reply on Laravel 5.6 Using Laracharts. Chart Wont Render • 1 month ago

To get lavachart work, I think you should have the render between a tag.

30th July, 2018

esorone left a reply on Undefined Variable: Chart After @include • 1 month ago

Hello Both,

Thanks for you answer. And therefor I chose an other approach. I created a partial which I used in my chart.chart_view and no one notice the difference.

I prefer to have a separate chart controller, so all the chart will be in this controller and (for me) easier to manage.

@lostdreamer thanks for the dutch remark. Ill keep this in mind for the next time.

esorone left a reply on Undefined Variable: Chart After @include • 1 month ago

Hello Both,

Thanks for you answer. And therefor I chose an other approach. I created a partial which I used in my chart.chart_view and no one notice the difference.

I prefer to have a separate chart controller, so all the chart will be in this controller and (for me) easier to manage.

@lostdreamer thanks for the dutch remark. Ill keep this in mind for the next time.

esorone started a new conversation Undefined Variable: Chart After @include • 1 month ago

Hello All,

I think I got a simple problem, but I still need some help.
I have a simple chart controller, which return data to a view.
When I check the view, it all runs well. But if I include this view with :" @include('charts.chart_view')" I receive the undefined variable: chart error.

My Chart Controller:

<?php

namespace App\Http\Controllers;

use App\Post;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use ConsoleTVs\Charts\Facades\Charts;

class ChartController extends Controller
{
    public function aantalPostsPerMaand()
    {
        $users = Post::where(DB::raw("(DATE_FORMAT(created_at,'%Y'))"),date('Y'))
                    ->get();
        $chart = Charts::database($users, 'bar', 'highcharts')
                  ->title("Aantal aangemaakte registraties per maand")
                  ->elementLabel("Totaal Registraties")
                  ->dimensions(1000, 400)
                  ->responsive(true)
                  ->groupByMonth(date('Y'), true);

        return view('charts.chart_view',compact('chart'));
    }
}

The view charts.chart_view. Which works completely fine!

@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row">
        <div class="col-md-12">
            <div class="panel panel-default">
                <div class="panel-heading">Chart Demo</div>
                <div class="panel-body">
                    {!! $chart->html() !!}
                </div>
            </div>
        </div>
    </div>
</div>
{!! Charts::scripts() !!}
{!! $chart->script() !!}
{!! link_to(URL::previous(), 'Terug', ['class' => 'btn btn-default', 'style'=> 'color:white']) !!}
@endsection

And my @include in the dashboard.

                    <div class="chart">

 @include('charts.chart_view')

                    </div>

I can imagine that the " public function aantalPostsPerMaand()" is not called during the @include, but I'm not sure how to solve it.

23rd July, 2018

esorone left a reply on Best Design Tool For Front-end • 1 month ago

Hello,

Maybe an oldskool answer to help you on Your jouney. Please use the slice tool in PS. If you can slice it in, Let say square parts you should able to code it pretty easily. My advice is not to use the actual slices, but you will notice the importance of a (web) design. Of course there some nifty css options, to make it more fancy and create rounds and radius. But that’s advanced. If you cannot slide it, then you need to use the image as a background and make the image responsive.

FYI, responsive is all about grids and the layout. I think you designs are not easy to put in a grid. That’s way I made my slice remark, and start with a mobile first design first

Also try design you image in a mobile template in PS.. And solve some issues over there.

Kr

4th June, 2018

esorone left a reply on SOLVED: DateDiff: The Separation Symbol Could Not Be Found Unexpected Data Found. Trailing Data • 3 months ago

Thanks for the eagle eye . Im DEV on macOs, and I thought this was case sensitive as well. I adjusted the code.

Thanks again.

esorone left a reply on Opening Already Created Projects • 3 months ago

I quess you shoul run PHP artisan serve from a command prompt. Make sure that you are in Your app folder.

After this open Your webbrowser and type 127.0.0.1:8000

Kr

3rd June, 2018

esorone left a reply on Chat System For Customers • 3 months ago

https://crisp.chat/en/ can do the job as well.

esorone left a reply on DateDiff: The Separation Symbol Could Not Be Found Unexpected Data Found. Trailing Data • 3 months ago

Hey Cronix,

I solved the issue, just by taking another approach.

In my store function I added:

            $startTime = Carbon::parse($request->starttijd);
            $finishTime = Carbon::NOW();
            $totalDuration = $finishTime->diffinSeconds($startTime);

           $post->seconds = $totalDuration;

With this approach I only store the actual passed seconds..

Thanks for you help.

esorone left a reply on DateDiff: The Separation Symbol Could Not Be Found Unexpected Data Found. Trailing Data • 3 months ago

Hello Cronix,

First of all, thanks for the reply. I tried the diffinSeconds before, but it did not work out. I changed per your advice and I ran against a new problem.

"DateTime::__construct(): Failed to parse time string ([{"seconds":"2018-06-02 15:46:25"},"

Hope you see my mistake.

My controller:

public function index() {

        $posts = Post::sortable()->paginate(20);
        $categories = HoofdCategory::sortable()->paginate(20);
        $subcategories = Subcategory::sortable()->paginate(20);
        $users = User::sortable()->paginate(20);

        $start = Post::select('seconds')
              ->get();
        $end = POST::select('updated_at')
              ->get()->first();

// dd($start);

        $startTime = Carbon::parse($start)->format('H:i:s');
        $endTime = Carbon::parse($end)->format('H:i:s');

        $startTime = Carbon::parse($start);
        $endTime = Carbon::parse($end);

        $diff = $endTime->diffInSeconds($startTime);


        return view('posts.index', compact('posts','categories','subcategories','users'));
        }

esorone started a new conversation DateDiff: The Separation Symbol Could Not Be Found Unexpected Data Found. Trailing Data • 3 months ago

Goodafternoon,

After two whole days trying to solve this issue, I hope some of you can help me out.

in my PostController I store an extra data field, called "seconds" This is the start time of an form being opened

        $post->seconds = Carbon::parse($seconden);

This is stored in the mysql database in the column called seconds : "2018-06-03 16:15:55". database Type = TIMESTAMP. The created_at value in the same request is: = "2018-06-03 16:16:04"

Now I try to subtract the created_at - seconds, so I know the exact handle time of this form.

Unfortunately I ran to numerous errors, and I (think) I solved them one by one. But still got one left: "Unexpected data found. The separation symbol could not be found Unexpected data found. Trailing data" on dd($diff);

The index controller is:

    public function index() {

        $posts = Post::sortable()->paginate(20);
        $categories = HoofdCategory::sortable()->paginate(20);
        $subcategories = Subcategory::sortable()->paginate(20);
        $users = User::sortable()->paginate(20);

        $start = Post::select('seconds')
              ->get();
        $end = POST::select('updated_at')
              ->get();

// dd($start);

        $startTime = Carbon::createFromFormat('H:i:s', $start);
        $endTime = Carbon::createFromFormat('H:i:s', $end);

        $diff = $endTime - $startTime;
        dd($diff);

        return view('posts.index', compact('posts','categories','subcategories','users'));
        }

the output for e.g. dd($start) = "seconds" => "2018-06-02 15:46:25"

I hope some one can help me out on:

The separation symbol could not be found Unexpected data found. Trailing data" on dd($diff);

26th April, 2018

esorone started a new conversation SQLSTATE[HY000] [2002] Connection Refused FRESH INSTALL • 4 months ago

Hello All,

I just did a fresh install and I ran a "php artisan make:aut", after this I ran php artisan "migrate".. Everything runs fine and the tables are created. But when I try to register on http://127.0.0.1:8000/register and fill out all the fields, I receive a connection refused. The migrate work as it suppose to do and create the user table. So the connection details should be okay.

I use a external database and I develop the application locally. (which I did numerous times) and other applications works really okay. The only change in the .env compared to others application is the DB_DATABASE=NAME

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:8RCrg0ZFZE
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=xxx.xxx.xxx.xxx
DB_PORT=3306
DB_DATABASE=xanv
DB_USERNAME=niceusername
DB_PASSWORD=eriqweru8202j

In the error log remote address is still see the localhost ip 120.0.0.1

Server/Request Data
DOCUMENT_ROOT   
"/Users/username/www/Xanv/xanv/public"
REMOTE_ADDR 
"127.0.0.1"
REMOTE_PORT 
"57519"
SERVER_SOFTWARE 
"PHP 7.1.7 Development Server"
SERVER_PROTOCOL 
"HTTP/1.1"
SERVER_NAME 
"127.0.0.1"
SERVER_PORT 
"8000"
REQUEST_URI 
"/register"
REQUEST_METHOD  
"POST"
SCRIPT_NAME 
"/index.php"
SCRIPT_FILENAME 
"/Users/username/www/Xanv/xanv/public/index.php"
PATH_INFO   
"/register"
PHP_SELF    
"/index.php/register"
HTTP_HOST   
"127.0.0.1:8000"
HTTP_CONNECTION 
"keep-alive"
CONTENT_LENGTH  
"140"
HTTP_CONTENT_LENGTH 
"140"
HTTP_CACHE_CONTROL  
"max-age=0"
HTTP_ORIGIN 
"http://127.0.0.1:8000"
HTTP_UPGRADE_INSECURE_REQUESTS  
"1"
CONTENT_TYPE    
"application/x-www-form-urlencoded"
HTTP_CONTENT_TYPE   
"application/x-www-form-urlencoded"
HTTP_USER_AGENT 
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
HTTP_ACCEPT 
"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"
HTTP_REFERER    
"http://127.0.0.1:8000/register"
HTTP_ACCEPT_ENCODING    
"gzip, deflate, br"
HTTP_ACCEPT_LANGUAGE    
"en-GB,en-US;q=0.9,en;q=0.8"
HTTP_COOKIE 
"admin_auth=eyJpdiI6Ild0UkNRWUo2TmlBTkFJT1wvT095anR3PT0iLCJ2YWx1ZSI6IkJYNUZwbHZvNFQ0R0NCVlpBQW50UHlNUGNkQko5S25wWmpZamNxVlJpdVFzMTB0ZytUVDF4S0Q4cDFSWEtRSHFHYjRiM ▶"
REQUEST_TIME_FLOAT  
1524774661.2852
REQUEST_TIME    
1524774661
argv    
[]
argc    
0


The database.php

        'mysql' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'strict' => true,
            'engine' => null,
        ],

So I hope someone of you can help me out.

Kr Lennard

7th April, 2018

esorone left a reply on Again Undefined Variable: :-( • 5 months ago

Thanks, Is was a typo. I did not see it at all. So G / Q

esorone started a new conversation Again Undefined Variable: :-( • 5 months ago

Hello All,

I lasttime I ran into such an error, you guys saw the error instantly. One stupid error, which I checked numerous times.

I got a blade template in which I call the var = $guess. {{ $guess }}. But I receive the Undefined variable

My controller: ($guess is at the end)

class LessonsController extends Controller
{

    public function show($course_id, $lesson_slug)
    {
        $lesson = Lesson::where('slug', $lesson_slug)->where('course_id', $course_id)-      >firstOrFail();

        if (\Auth::check())
        {
            if ($lesson->students()->where('id', \Auth::id())->count() == 0) {
                $lesson->students()->attach(\Auth::id());
            }
        }

        $test_result = NULL;
        if ($lesson->test) {
            $test_result = TestsResult::where('test_id', $lesson->test->id)
                ->where('user_id', \Auth::id())
                ->first();
        }

        $previous_lesson = Lesson::where('course_id', $lesson->course_id)
            ->where('position', '<', $lesson->position)
            ->orderBy('position', 'desc')
            ->first();
        $next_lesson = Lesson::where('course_id', $lesson->course_id)
            ->where('position', '>', $lesson->position)
            ->orderBy('position', 'asc')
            ->first();

        //  $quess = Question::where ('guess',1)->get();

        $purchased_course = $lesson->course->students()->where('user_id', \Auth::id())->count() > 0;
        $test_exists = FALSE;
        if ($lesson->test && $lesson->test->questions->count() > 0) {
            $test_exists = TRUE;
        }     
        
       $guess = Question::where ('guess',1)->get();
    //    dd($guess);

        return view('lesson', compact('lesson', 'previous_lesson', 'next_lesson', 'test_result',
            'purchased_course', 'test_exists','quess'));
    }

All the variables of the compact work, expect the guess one.

The output of dd($guess)

Collection {#391 ▼
  #items: array:2 [▼
    0 => Question {#392 ▶}
    1 => Question {#393 ▶}
  ]
}

This is exactly the outcome.

I the view I did

<h2> {{ $quess }}</h2>  

Which results in the error.

I hope someone on you guys can help me again.

Kr

6th August, 2017

esorone left a reply on Adding A Bootstrap Template To A Laravel 5.4 Project. • 1 year ago

If you check "inspect element"(right mouse Button) in Chrome or Firefox, is the css being loaded? You can see this just on the css classes or go to resources tab.

Kr

4th August, 2017

esorone left a reply on Undefined Variable: • 1 year ago

That's what i meant with a really stupid error.!!. I did check this zillion times.

Thanks you!

esorone started a new conversation Undefined Variable: • 1 year ago

Hello All,

I ran into issues, which causes me a real headache. I guess I'm doing something really stupid, but I cannot find the error.

Its all about Undefined variable: Overview.

The only thing I would like to show is an overview of some results. My resultsController:

/**
     *Show overview per user
     */

        public function overview()
        {
        $results = Result::all()->load('user');
        $results = $results->where('user_id', '=', Auth::id());
            // dd($results);
        return view ('users.overview', compact('results'));

        }

Outcome of my DD:

Collection {#440 ▼
  #items: array:1 [▼
    0 => Result {#433 ▼
      #fillable: array:4 [▼
        0 => "correct"
        1 => "date"
       ** 2 => "user_id" **
        3 => "question_id"
      ]
      #connection: null
      #table: null
      #primaryKey: "id"
      #keyType: "int"
      #perPage: 15
      +incrementing: true
      +timestamps: true
      #attributes: array:8 [▶]
      #original: array:8 [▶]
      #relations: array:1 [▶]
      #hidden: []
      #visible: []
      #appends: []
      #guarded: array:1 [▶]
      #dates: []
      #dateFormat: null
      #casts: []
      #touches: []
      #observables: []
      #with: []
      +exists: true
      +wasRecentlyCreated: false
      #forceDeleting: false

And My overview.blade.php:

@section('content')
    <div class="main-container">
        <div class="row background">
            <div class="col-xs-12 marge-top">
            <h1>Account Overview</h1>
                {{ $overview->user_id }}
            </div>
        </div>
    </div>  

Unfortunately I receive the mentioned error. I hope someone can help me out

11th October, 2016

esorone left a reply on @if Not Working On Production Server • 1 year ago

@christopher

Here is the outcome of dd($comments) , which i ran from my blade file {!! dd($comment) !!} As fas I can determine "aanwezig" => 1", So this is equal to ($comment->aanwezig === 1)

Comment {#221 ▼ #connection: null #table: null #primaryKey: "id" #keyType: "int" #perPage: 15 +incrementing: true +timestamps: true #attributes: array:7 [▼ "id" => 55 "comment" => "Ik ben er. Ik moet wel werken tot 17:00 in Amsterdam, dus het wordt krap. Maar het is mijn allerlaatste werkdag :-)" "post_id" => 17 "user_id" => 13 "aanwezig" => 1 "created_at" => "2016-09-23 14:30:34" "updated_at" => "2016-10-11 18:35:01" ] #original: array:7 [▶] #relations: array:1 [▶] #hidden: [] #visible: [] #appends: [] #fillable: [] #guarded: array:1 [▶] #dates: [] #dateFormat: null #casts: [] #touches: [] #observables: [] #with: [] #morphClass: null +exists: true +wasRecentlyCreated: false }

esorone left a reply on @if Not Working On Production Server • 1 year ago

Hello Zachleigh. The $comment->aanwezig returns a integer. My test environment has version: php -v PHP 7.1.0beta1 (cli) (built: Jul 29 2016 07:50:40) ( NTS )

My prod environment: PHP 7.0.11-1~dotdeb+8.1 (cli) ( NTS )

So not entirely the same but ì guess this should not be a problem... (i guess). Any ideas left?

9th October, 2016

esorone left a reply on @if Not Working On Production Server • 1 year ago

Hello

Thank you for your swift response. The test db and the production database are the exact same database. I do not have a seperate one at this stage. (Really small hobby app, for education purposes only)

esorone started a new conversation @if Not Working On Production Server • 1 year ago

Hello There,

I have a strange question. I developing on a local machine and use git to push it to the production environment. But my ===1 is not working. I share the same database so that could not be the case. I guess it is a kind of setting in the live environment. The production shows only the "glyphicon glyphicon-remove". It doesn't care $comment->aanwezig === 1 is valid or not. Does someone have any idea and can help me out?

Kr Lennard

So the code underneath is working on test, but not on the production environment.

                            <div class="text-right">
                                @if ($comment->aanwezig === 1)
                                    <span class="glyphicon glyphicon-ok"></span>
                                @else <span class="glyphicon glyphicon-remove"></span>
                                @endif
                            </div>

19th September, 2016

esorone started a new conversation Need Help For Distinct Value In Blade • 2 years ago

Need help for distinct value in blade

Hey There,

I recently start using Laravel and I must say I like it. But still I have to learn lots of syntaxes and tricks.

I'm creating a small webapp. The user can make some comments and there is a checkbox if someone is participating a event or not.. This is calls "Aanwezig" in Dutch.

The user can change there presents with the checkbox. Just edit or create a new comment. This will result in multiple records in de database. This is the way i would like it to be.

But now I run into a problem. I would like to show a users avatar on a index.page. This works fine, but a user is shown multiple times. Because of my records. My question is, what is the best approach to "show a distinct user"

Image of MySql

Image of MySql

My code

                    @foreach($post->comments as $comment)
                        <img class="user_img_overzicht" src="{{ asset('images/'. $comment->user->avatar) }}" alt="avatar" />
                    @endforeach
Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.