mleontenko

mleontenko

Member Since 2 Years Ago

Experience Points
4,820
Total
Experience

180 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
41
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

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

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

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

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    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 Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

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

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

Level 1
4,820 XP
Feb
19
5 days ago
Activity icon

Replied to One To Many Relation In Forms (without JavaScript)

Ok, I understand that this is impractical to implement with pure PHP because it would refresh the page on button click, but is there any library/package that helps me do something like this in laravel?

What I'm trying to do is avoid writing custom JS code that handles button click events and DOM manipulation because this way of handling many-to-many relationships seems like something that is used commonly in web forms. The values are sent to the controller as an array and are easy to handle after that.

Activity icon

Started a new Conversation One To Many Relation In Forms (without JavaScript)

I have a form for adding address to a user. One user can have anything from zero to dozens of addresses (one to many relationship in database).

Is there a simple way to create a form in Laravel that allows the user to add or delete address fileds without writing custom JavaScript code that handles add/delete buttons?

It should look something like this:

View post on imgur.com
Oct
05
4 months ago
Activity icon

Started a new Conversation Migrations - Adding Columns With FALSE As Default Value

I'm using a migration that adds "verified" column to users table:

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddVerifiedColumn extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('users', function (Blueprint $table) {            
            $table->boolean('verified')->deafult(false);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('users', function (Blueprint $table) {
            $table->dropColumn('verified');
        });
    }
}

The goal is to add "verified" column and set it to false for all current users and future registered users.

When I try to run php artisan migrate, I get the following error:

SQLSTATE[23502]: Not null violation: 7 ERROR:  column "verified" contains null values (SQL: alter table "users" add column "verified" boolean not null)

Why does it contain null values? It should contain boolean value: false.

EDIT: database is postgreSQL

Activity icon

Replied to Prevent Unverified Users From Logging In (Laravel 6.x)

Is there an example of this? I'm having trouble implementing this. I never used middleware.

I'm using default login controller:

<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;

class LoginController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Login Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles authenticating users for the application and
    | redirecting them to your home screen. The controller uses a trait
    | to conveniently provide its functionality to your applications.
    |
    */

    use AuthenticatesUsers;

    /**
     * Where to redirect users after login.
     *
     * @var string
     */
    protected $redirectTo = '/map';

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest')->except('logout');
    }
}

I just want to check inside controller if user is verified before I allow them to login.

Oct
04
4 months ago
Activity icon

Started a new Conversation Prevent Unverified Users From Logging In (Laravel 6.x)

I added "verified" column (boolean) to users table. I'm planning to manually verify users in database. I don't want email verification.

Now I need to prevent unverified users from logging into my app. What is the best way to do this? I' using default laravel login window and I only need to display the message: "Your account is not verified" if they try logging in before verification.

Oct
03
4 months ago
Activity icon

Started a new Conversation Multiple Custom .js Files

I have some custom .js code that I load into my view (bottom of body tag) like this:

<!-- Compiled JS from libraries -->
<script src="{{ asset('js/app.js')}}"></script>

<!-- Custom JS  -->
<script src="{{ asset('js/guestapp.js')}}"></script>
@auth
  <script src="{{ asset('js/adminapp.js')}}"></script>
@endauth

adminapp.js is loaded only for authenticated users.

Some code in adminapp.js is dependent on code in guestapp.js. Are these scripts executed synchronously? The application will bug if adminapp.js runs before guestapp.js is finished.

Oct
02
4 months ago
Activity icon

Started a new Conversation Limiting Number Of Characters In Blade View (laravel 6.x)

I have paragraph element in my blade template:

<p class="card-text">{{ $location->description }}</p>

Is there a way to limit number of characters, because the text in $location->description variable is sometimes too long and it messes with my layout.

I need something like this (https://laravel.com/docs/6.x/helpers#method-str-limit) but to use it in blade template instead of controller.

Sep
28
4 months ago
Activity icon

Started a new Conversation 401 Unauthorized POST Request With JQuery

I'm using jQuery script in one of my views to send POST request to my API route in Laravel 6:

The request looks like this:

$.ajax({
            type: 'POST',
            headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')},
            url: 'api/location',            
            data: {
                'opis': opis,
                'geom': geometry
            },
            success: function(msg){
                console.log(msg);
            }
        });

The route is registered in routes/api.php:

Route::resource('location', 'LocationController');

I'm getting the following response in my developer tools network section:

{"message":"Unauthenticated."}

Headers section looks like this:

General:

Request URL: http://localhost:8000/api/location
Request Method: POST
Status Code: 401 Unauthorized
Remote Address: 127.0.0.1:8000
Referrer Policy: no-referrer-when-downgrade

Response headers:

Cache-Control: no-cache, private
Connection: close
Content-Type: application/json
Date: Sat, 28 Sep 2019 15:56:49 GMT, Sat, 28 Sep 2019 15:56:49 GMT
Host: localhost:8000
X-Powered-By: PHP/7.3.6

Request headers:

Accept: */*
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Origin: http://localhost:8000
Referer: http://localhost:8000/map
Sec-Fetch-Mode: cors
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36
X-CSRF-TOKEN: Bsh4Sd5Dyb3m1dbeywzoG3pqrMFXYNNUbdYv9PFF
X-Requested-With: XMLHttpRequest

Form data:

opis: sfjsfgj
geom: {"type":"Polygon","coordinates":[[[16.611328,45.92823],[17.391357,45.552525],[16.940918,45.290347],[16.611328,45.92823]]],"crs":{"type":"name","properties":{"name":"EPSG:4326"}}}

What is the problem? I'm sending csrf token in request header. Is there something else I shoud do/configure?

Sep
24
5 months ago
Activity icon

Started a new Conversation Using JavaScript Libraries In Laravel View Components (6.x)

I'm trying to add leaflet.js map to my laravel project.

Leaflet is installed via

npm install leaflet

After that, I used this to compile assets:

npm run dev

I have a view (map.blade.php) in which I'm trying to use leaflet like this:



<!DOCTYPE html>
<html>
<head>
    
    <title>Quick Start - Leaflet</title>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    
</head>
<body>



<div id="mapid" style="width: 600px; height: 400px;"></div>

<script>

    var mymap = L.map('mapid').setView([51.505, -0.09], 13);

    L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw', {
        maxZoom: 18,
        attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' +
            '<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
            'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
        id: 'mapbox.streets'
    }).addTo(mymap);

    L.marker([51.5, -0.09]).addTo(mymap)
        .bindPopup("<b>Hello world!</b><br />I am a popup.").openPopup();

    L.circle([51.508, -0.11], 500, {
        color: 'red',
        fillColor: '#f03',
        fillOpacity: 0.5
    }).addTo(mymap).bindPopup("I am a circle.");

    L.polygon([
        [51.509, -0.08],
        [51.503, -0.06],
        [51.51, -0.047]
    ]).addTo(mymap).bindPopup("I am a polygon.");


    var popup = L.popup();

    function onMapClick(e) {
        popup
            .setLatLng(e.latlng)
            .setContent("You clicked the map at " + e.latlng.toString())
            .openOn(mymap);
    }

    mymap.on('click', onMapClick);

</script>



</body>
</html>


I'm getting the following error: Uncaught ReferenceError: L is not defined at map:25

Now, I understand that this is because leaflet library is not loaded properly, but I don't know what is the best way to load it so I can use it in this view?

Activity icon

Replied to Migration Problems (PostgreSQL)

That's it! Thanks

Activity icon

Started a new Conversation Migration Problems (PostgreSQL)

I started using laravel 6.0 and I'm trying to set up authentication in my app.

I used:

composer require laravel/ui --dev

and

php artisan ui vue --auth

After that I ran:

npm install

npm run dev

Now i have UI elements for login /register.

In my config/database.php I set up default database to PostgreSQL

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

In .env file I configured:


DB_CONNECTION=pgsql
DB_HOST=localhost
DB_PORT=5432
DB_DATABASE=myapp
DB_USERNAME=postgres
DB_PASSWORD=mypass

Now, I'm trying to run migration with:

php artisan migrate

I'm getting the following error and cant find soluton to it:


 Illuminate\Database\QueryException  : could not find driver (SQL: select * from information_schema.tables where table_schema = public and table_name = migrations and table_type = 'BASE TABLE')

  at C:\xampp\htdocs\posumljavanje\vendor\laravel\framework\src\Illuminate\Database\Connection.php:665
    661|         // If an exception occurs when attempting to run a query, we'll format the error
    662|         // message to include the bindings with SQL, which will make this exception a
    663|         // lot more helpful to the developer instead of just the database's errors.
    664|         catch (Exception $e) {
  > 665|             throw new QueryException(
    666|                 $query, $this->prepareBindings($bindings), $e
    667|             );
    668|         }
    669| 

  Exception trace:

  1   PDOException::("could not find driver")
      C:\xampp\htdocs\posumljavanje\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70

  2   PDO::__construct("pgsql:host=localhost;dbname=posumljavanje;port=5432;sslmode=prefer", "postgres", "Leontenko2", [])
      C:\xampp\htdocs\posumljavanje\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70

  Please use the argument -v to see more details.