esorone

esorone

Member Since 2 Years Ago

Experience Points 8,170
Experience Level 2

1,830 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 47
Lessons
Completed
Best Reply Awards 3
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

26 Apr
1 month ago

esorone left a reply on How Can I Get Data From Database?

I do not know what the totalmark means, but you can call the $totalMarks variable in blade just as you did with the $suggestions var.

15 Apr
2 months ago

esorone left a reply on Extract Only Useful CSS Files/rules And JS Code

Hey,

Indeed merge the files and after this you can use e.g. https://purifycss.online/ to delete unused css classes. But the site should be online a.f.a.i.k.

Kr

06 Apr
2 months ago

esorone left a reply on Composer Keeps Installing Package

Hello Cronix,

As far as I can see no. I searched for pagemanager throughout the project and did not find any require pagemanager..

But, I removed all dependencies of backpack and after this I installed backpack again and the pagemanager was not installed anymore. So somewhere there was a dependency.

Thx.

esorone left a reply on Composer Keeps Installing Package

Hello.

The name of the Package is: backpack/pagemanager. It is an add on on backpack

esorone started a new conversation Composer Keeps Installing Package

Hello All,

I got some irritating package.

I tried to remove this one, but when I run composer update, the package will be installed again.

I tried numerous ways, including: 1: Manual remove the package from composer.json and ran composer update. 2: Manual remove all the package content, including the vendor part. 3: Removed it from composer.json and Composer.lock and ran composer update 4: composer remove package 5: deleted the service provider.

I cleared my cache, and I ran optimise:clear as well. I did a composer clear-cache and a rm -fR ~/.cache/composer

Did a ctrl F to find all the references of this package, and deleted this.

I also installed the package again, and tried to remove it. This resulted in "Dependency "laravel/framework" is also a root requirement, but is not explicitly whitelisted. Ignoring."

But if I run a composer update, this package will be installed again :-(.....

I hope some of you guys can help me out to remove this package.. Unfortunately this is in one git branch, with I already made some development, so roll back a commit will not help :-(

Thanks in advanced.

04 Apr
2 months ago

esorone left a reply on How To Hide And Display Table

Hello,

Maybe the example underneath will help you a little. It is a example based on a checkbox.

The FORM:

    
              <div class="form-check form-check-inline">
            <input type="checkbox" class="form-check-input" id="afleverUnchecked">
            <label class="form-check-label" for="afleverUnchecked">Order delivery Address?</label>
            </div>
    
    
    
            <div id="unhide">        
            <div class="form-check form-check-inline">
              <input type="checkbox" class="form-check-input" id="samename">
              <label class="form-check-label" for="samename">Same?</label>
            </div>
            <div class="row">
              <div class="col-md-6 mb-3">
                <div class="md-form md-outline my-2">
                  <input type="text" id="affirstName" name="affirstName" class="form-control"           placeholder="FirstName" required>
                </div>
              </div>
           </div>
            <!-- end unhide -->
          </div>

script:

    <script>
      $(function () {
        // Get the form fields and hidden div
        var checkbox = $("#afleverUnchecked"); 

        var hidden = $("#unhide");
        hidden.hide();
        checkbox.change(function () {
          if (checkbox.is(':checked')) {
            hidden.show();
          } else {
            hidden.hide();
          }

        });
      });
    </script>

Kr

esorone left a reply on Error 500

Hello,

The error is really generic, but there could be some reasons. Unfortunately you have to debug them

  1. Missing PHP extensions
  2. Wrong file or folder permissions
  3. Application key not generated or invalid
  4. Environment (“.env”) file not set
  5. Outdated composer
  6. Stale Laravel config cache
  7. Code sync errors

This list is from the URL mentioned underneath and you can find more info there.

https://bobcares.com/blog/laravel-something-went-wrong/

Kr

esorone left a reply on Regexp Explanation

Hello,

Did you know that there is a serie regarding regex? https://laracasts.com/series/understanding-regular-expressions

This will help to get some background regarding the topic.

But you expression looks like: "validation expression which is for eight characters including one uppercase letter, one lowercase letter, and one number or special character."

29 Mar
2 months ago

esorone left a reply on PHPStorm And Laravel Snippets Like SublimeText

Hello, Maybe you already follow the documentation of PHP Storm and laravel, But here you can find more info on how to setup Laravel for PHP Storm. For me it worked.

https://www.jetbrains.com/help/phpstorm/laravel.html

23 Feb
4 months ago

esorone left a reply on Carbon Throwing Errors In Lamp Server

Hello,

Did you add carbon to you controller? E.g. use Carbon\Carbon

Kr

22 Feb
4 months ago

esorone left a reply on How To Manage VPS And Deploy Laravel Applications?

Hello Pavelas,

A couple of weeks there was a sort of the same question. This could give you an head start .

https://laracasts.com/discuss/channels/laravel/launching-laravel-on-a-vps

There are Some links to tutorials as well.

Some Answers: you can have multiple domains on a VPS, just create vhosts. It is possible to set up a mail server for sending and receiving emails. Laravel has some requirement for database and php. So if you choose for a lamp package, you need to takes this into consideration as well.

Regarding OS, if you ask 10 people, you will get 9 good, but different answers. I will go for Ubuntu.. (is one of the tutorials as well.)

Good luck.

15 Feb
4 months ago

esorone left a reply on Method 'table' Not Found In \Illuminate\Support\Facades\DB

Hello,

Can you show us the outcome of dd($users);

Kr

14 Feb
4 months ago

esorone left a reply on HTML/CSS Animation?

Hello,

The example you use, is this an actual example, so online? If so, you could check the code how it is build via e.g. devtools.

I guess you can do it will the use of multiple techniques and guided animation. I found: https://go.tiny.cloud/blog/guide-svg-animation/ . Maybe this can help you on this journey of the animation. The pop-up and button is "just" standard jquery and CSS.

Kr

07 Feb
4 months ago

esorone left a reply on Does Anyone Can Make My Code Simple ?

Hey,

Indeed difficult to interpret what you mean, but I guess I understand you question.

I would opt for a different approach. I would add an extra column to your post table. for example "view_count".

$table->integer('view_count')->default(0);

I would then update these view_count column every time when the post is viewed. And finally you can easily show this post via a max(view_count) query.. So al in one postController

I found a (old) tutorial, but is give you an idea how to implement a view count. https://stidges.com/implementing-a-page-view-counter-in-laravel

Kr

01 Feb
4 months ago

esorone left a reply on SQLSTATE[42S22]: Column Not Found: 1054 Unknown Column

Thanks D9705996

AHHHHH

I did even a search query for the name Category in VSCODE and still did not notice this one.

31 Jan
4 months ago

esorone started a new conversation SQLSTATE[42S22]: Column Not Found: 1054 Unknown Column

Hello all,

Sometimes I feel like king of the stupid questions, if I read your answers, but sometimes I have the feeling that im looking for a needle in a haystack and it turnout to be a Q instead of G..

Again I need your help.

I receive the " SQLSTATE[42S22]: Column not found: 1054 Unknown column 'amount' in 'field list' (SQL: insert into categories (amount, created_at, enddate, leveringsadres, startdate, tnv, updated_at, user_id) values (10, 2019-01-31 21:38:23, 2 019-01-29 17:06:37, teststraat 23, 2019-01-28 19:06:37, user1, 2019-01-31 21:38:23, 1))

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'amount' in 'field list

"

error when I run php artisan db:seed. Before i run this comment I always do a php artisan migrate:refresh.

Indeed, the column amount is not known in the categories table, because I'm not trying to seed into categories, but in checkouts.

I already tried to clear cache and reset migrations, composer dump-autoload etc. But still when I run php artisan db:seed I receive the mentioned error. I even tried to leave the '' 'amount' => '10', and wrote 'amount' => 10,. Just trail and error.

FYI the categories seeder works perfect.

I hope someone can help me out.

Please see my Seeder and Migration file.

Create Checkout table

class CreateCheckoutsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('checkouts', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('amount');
            $table->integer('user_id');
            $table->string('tnv');
            $table->string('leveringsadres');
            $table->date('startdate');
            $table->date('enddate');
            $table->timestamps();
        });
    }

Checkout Table Seeder.

class CheckoutTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $now = Carbon::now()->toDateTimeString();

        Category::insert([
            ['amount' => '10', 'user_id' => '1',
                'tnv' => 'user1', 'leveringsadres' => 'teststraat 23',
                'startdate' => '2019-01-28 19:06:37',
                'enddate' => '2019-01-29 17:06:37',
                'created_at' => $now, 'updated_at' => $now],
        ]);
    }
}

Create Categories Table

class CreateCategoriesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('categories', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name')->unique();
            $table->string('slug')->unique();
            $table->timestamps();
        });
    }

Categories Seeder.

class CategoriesTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $now = Carbon::now()->toDateTimeString();
        Category::insert([
            ['name' => 'Partijtent', 'slug' => 'partytent', 'created_at' => $now, 'updated_at' => $now],
            ['name' => 'Ballonnen', 'slug' => 'ballon', 'created_at' => $now, 'updated_at' => $now],
            ['name' => 'Springkussens', 'slug' => 'sprinkussen', 'created_at' => $now, 'updated_at' => $now],
            ['name' => 'Stormbanen', 'slug' => 'stormbaan', 'created_at' => $now, 'updated_at' => $now],
            ['name' => 'Geluid', 'slug' => 'geluid', 'created_at' => $now, 'updated_at' => $now],
            ['name' => 'Overig', 'slug' => 'overig', 'created_at' => $now, 'updated_at' => $now],
        ]);
    }
}

esorone left a reply on Unable To Update From 5.5.44 To 5.6

Thanks both,

I actually did not receive any error when running the above file. But i indeed updated the package one by one and it turn out that hardevinde causes the error as soon as I uncommented it. So it looks like due the fact that I used //, not error was shown in the output.

But I'm on 5.7 :-)

Thanks

25 Jan
5 months ago

esorone started a new conversation Unable To Update From 5.5.44 To 5.6

Hello All,

Ofcourse I would love to update to 5.7 but I have to go to 5.6 first. When I run my composer update, is says: Nothing to update .

composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)

Nothing to install or update

Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover
Discovered Package: fideloper/proxy
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Package manifest generated successfully.

So no error message at all.

If I read the documentation correctly the only thing I have to do is:

Laravel 5.6 requires PHP 7.1.3 or higher. Update your laravel/framework dependency to 5.6.* and your fideloper/proxy dependency to ^4.0 in your composer.json file.

My composer.json.

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=7.1.3",
        "fideloper/proxy": "^4.0",
        "laravel/framework": "5.6.*",
        "laravel/tinker": "~1.0"
        // "hardevine/shoppingcart": "^2.5",
    },
    "require-dev": {
        "filp/whoops": "~2.0",
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "^7.0"
    },
    "autoload": {
        "classmap": [
            "database/seeds",
            "database/factories"
        ],
        "files": [
            "app/helpers.php"
        ],
        "psr-4": {
            "App\": "app/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "scripts": {
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate"
        ],
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover"
        ]
    },
    "config": {
        "preferred-install": "dist",
        "sort-packages": true,
        "optimize-autoloader": true
    }
}

I hope someone is able to spot my error.

20 Jan
5 months ago

esorone left a reply on Best Practice In Field Naming Vs Validation

Hey Adesugbaa,

Great workaround!... I should come up with this idea myself :-)

esorone left a reply on How Do I Add Theme Template Css And Js In The Laravel And Vue ?

Hello,

Did you check if the CSS and JS is actually loaded? With e.g. development tools in Chrome? (Sheet sources). If this is the case, then the file are at least loaded.

Kr

esorone started a new conversation Best Practice In Field Naming Vs Validation

Hello All,

I "always" try to follow best practices and based on some feedback in the past at this forum, I changes my way of working when I'm developing forms. One of the feedback was not to translate the form names. (label excluded). So now I have a address form, and yes, sometimes I work with English friends, so not translating is always handy.

                 <div class="form-group">
                    <label for="address">Adres</label>
                    <input type="text" class="form-control" id="address" name="address" value="         {{old('address')}}">
                </div>

So far so good, but when use a validation on this form with an error message, I ofcourse get a strange result. Because in Dutch, address = adres, but the validation message show address

e.g. error message: Het address veld is verplicht. instead of "Het adres veld is verplicht"

Any ideas how to tackle this one?

Thanks again.

11 Jan
5 months ago

esorone left a reply on The Page Has Expired Due To Inactivity. And @csrf

Hey Manelgavalda,

I got the same impression.. I did an update from 5.5 to 5.6. Maybe something went wrong.

Ill check the update... Thanks..

esorone left a reply on Launching Laravel On A VPS

Maybe you run into a .htaccess problem, sometimes this happens to me. But I do remember if it was on Nginx or Apache

Good luck

esorone started a new conversation The Page Has Expired Due To Inactivity. And @csrf

Goodafternoon all,

Im running into a strange issue on just one page. after submitting the submit button i receive th e "The page has expired due to inactivity." error.

This one is ofter related to csrf.

And I do not know why, but the @csrf is rendered as @csrf in the browser and I cannot see why.

I removed all the bells and whistles in blade and still (only on this page) the @csrf is rendered in plain text '@crsf'

                <form action="{{route('checkout.store')}}" method="POST">
                @csrf
                

                    <div class="form-group">
                        <label for="email">E-mailadres</label>
                        <input type="email" class="form-control" id="email" name="email" value="">
                    </div>     


                </form>

Does someone have a glue?

08 Jan
5 months ago

esorone left a reply on Launching Laravel On A VPS

Then I would start to install a vanilla Ubuntu on AWS. After this I would follow a tutorial.

@Qwertynik showed a tutorial of 16.04 but on https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-ubuntu-18-04 you find a newer version

I used the same steps, to get my VPS going. (Different VPS provider)

The only "difficult" part for me was creating the server block level (server blocks are similar to Apache's virtual hosts). This due the fact I was used to use Apache and this was my first nginx.

If you have any questions, just let us know.

esorone left a reply on Navbar: Vertical!! Why?

Hey,

I just used your code and added a JQuery CDN. In Safari and Chrome I see a horizontal navbar with a grey Background.

It even is responsive, but the toggle button does not work yet.

Maybe flush your cache in the browser?

    <link href="/css/app.css" rel="stylesheet">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <script   src="https://code.jquery.com/jquery-3.3.1.slim.min.js"   integrity="sha256-3edrmyuQ0w65f8gfBsqowzjJe2iM6n0nKciPUp8y+7E="   crossorigin="anonymous"></script>
07 Jan
5 months ago

esorone left a reply on Import Mysql File Into Mysql Linux

Related to the Power off.. Assuming that you query is about running a mySQL server in a VMWARE environment. Then it should not be necessary to reboot the VMware. Just restart the mySql server in Linux.

Depending on you Linux it is something like: /etc/init.d/mysqld restart. OR service mysqld restart OR service mysql restart

esorone left a reply on Launching Laravel On A VPS

Can you share your OS which you are going to use? And what kind of webserver are you going to use?

31 Dec
5 months ago

esorone left a reply on How To Close The Gray Bar

It is indeed hard to help, without the code and css, But you can try to shift above

Or if you do not need the graybar just remove the class.

17 Dec
6 months ago

esorone left a reply on MySQL Database Calculate Total Sum

Hello Christopher,

If it was up to me, I would indeed make a total column and store the (cost * quantity) value in a total column. If the table growth in records, it will save a tremendous amount of time and calculations. Now you only have to sum(Total) and other statistic possibilities as well. E.g. avg()

09 Dec
6 months ago

esorone left a reply on Syntax Error, Unexpected ';', Expecting ']' On Deployment

Pfff..... Sometimes I'm blind as he**

Thanks!!

07 Dec
6 months ago

esorone started a new conversation Syntax Error, Unexpected ';', Expecting ']' On Deployment

Hello all,

I created a small app for a friend, and I try to install the app on his shared hosting environment. Unfortenately the only access I have (within his hosting plan) is FTP. I uploaded the files, added a .htaccess in the root to make sure that it is redirected to /public/ and no 403 anymore.

But I still got the following error:

[2018-12-07 15:54:07] laravel.ERROR: syntax error, unexpected ';', expecting ']' {"exception":"[object] (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): syntax error, unexpected ';', expecting ']' at /home/grapes.nl/public_html/XANV/config/database.php:119)

I did not change the default config database.php and the line 119 is the last "];""

Does any of you have a clue what could be wrong?

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Default Database Connection Name
    |--------------------------------------------------------------------------
    |
    | Here you may specify which of the database connections below you wish
    | to use as your default connection for all database work. Of course
    | you may use many connections at once using the Database library.
    |
    */

    'default' => env('DB_CONNECTION', 'mysql'),

    /*
    |--------------------------------------------------------------------------
    | Database Connections
    |--------------------------------------------------------------------------
    |
    | Here are each of the database connections setup for your application.
    | Of course, examples of configuring each database platform that is
    | supported by Laravel is shown below to make development simple.
    |
    |
    | All database work in Laravel is done through the PHP PDO facilities
    | so make sure you have the driver for your particular database of
    | choice installed on your machine before you begin development.
    |
    */

    'connections' => [

        'sqlite' => [
            'driver' => 'sqlite',
            'database' => env('DB_DATABASE', database_path('database.sqlite')),
            'prefix' => '',
        ],

        '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' => false,
            'engine' => null,

        'pgsql' => [
            'driver' => 'pgsql',
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '5432'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8',
            'prefix' => '',
            'schema' => 'public',
            'sslmode' => 'prefer',
        ],

        'sqlsrv' => [
            'driver' => 'sqlsrv',
            'host' => env('DB_HOST', 'localhost'),
            'port' => env('DB_PORT', '1433'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8',
            'prefix' => '',
        ],

    ],

    /*
    |--------------------------------------------------------------------------
    | Migration Repository Table
    |--------------------------------------------------------------------------
    |
    | This table keeps track of all the migrations that have already run for
    | your application. Using this information, we can determine which of
    | the migrations on disk haven't actually been run in the database.
    |
    */

    'migrations' => 'migrations',

    /*
    |--------------------------------------------------------------------------
    | Redis Databases
    |--------------------------------------------------------------------------
    |
    | Redis is an open source, fast, and advanced key-value store that also
    | provides a richer set of commands than a typical key-value systems
    | such as APC or Memcached. Laravel makes it easy to dig right in.
    |
    */

    'redis' => [

        'client' => 'predis',

        'default' => [
            'host' => env('REDIS_HOST', '127.0.0.1'),
            'password' => env('REDIS_PASSWORD', null),
            'port' => env('REDIS_PORT', 6379),
            'database' => 0,
        ],

    ],

];


19 Sep
9 months ago

esorone left a reply on Save Toggle Data Into Db

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

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

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

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);
    }
}

18 Sep
9 months ago

esorone left a reply on Save Toggle Data Into Db

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.

17 Sep
9 months ago

esorone left a reply on Save Toggle Data Into Db

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

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

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

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

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?

15 Sep
9 months ago

esorone left a reply on Save Toggle Data Into Db

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?

14 Sep
9 months ago

esorone started a new conversation Save Toggle Data Into Db

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.

31 Aug
9 months ago

esorone left a reply on Wrong Pulldown Value Populated On Edit

Hello all,

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

Thx for your help again.

30 Aug
9 months ago

esorone started a new conversation Wrong Pulldown Value Populated On Edit

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.

28 Aug
9 months ago

esorone left a reply on Create Vhost Apche2

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

Kr

12 Aug
10 months ago

esorone left a reply on Mysql Throws Multiple Connection Errors [2002] & [2006]

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

I missed a “ after sharing_personal_experiences.

esorone left a reply on My Create This Code But Its Not Looking Good

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>