petrit

petrit

Member Since 4 Years Ago

Prishtina

Experience Points
52,360
Total
Experience

2,640 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
411
Lessons
Completed
Best Reply Awards
26
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 11
52,360 XP
26 Aug
3 weeks ago

petrit left a reply on How To Check If Variable Is Empty/null/NULL/not Set/0

Regarding the php documentation, the following values are considered to be empty:

- "" (an empty string)
- 0 (0 as an integer)
- 0.0 (0 as a float)
- "0" (0 as a string)
- NULL
- FALSE
- array() (an empty array)

And isset() function may be used for undefined variables. But in Laravel you have to be careful when dealing with collections.

23 Aug
4 weeks ago

petrit left a reply on Error Message When Validate Null Value !

You may use nullable rule. But I think you can validate your request using integrated rules on Laravel.

'avatar' => 'nullable|image|mimes:jpeg,jpg,png'

petrit left a reply on Self Join Query Is Too Slow

Why not using eloquent relationships?

Querying speed depends on how you database is organized. By indexing contact_type it could speed up a bit.

petrit left a reply on How To Insert Data From A Table In Database To Another ? Laravel

$dataFromTable1 = Table1::all();
foreach($dataFromTable1 as $data)
{
    Table2::create([
    'name' => $data->emri,
    'address' => $data->address
    ])

}
22 Aug
1 month ago

petrit left a reply on UNABLE TO BOOT UP VAGRANT

You have to enable hardware virtualization (VT-x). It can usually be enabled via your BIOS.

petrit left a reply on File Not Found On Resource_path()

resource_path() is a path to resource directory, so storage_path() is a path storage directory. Maybe File facade will work

\File::copy(
    resource_path('email-attachments/' . $filename),
    storage_path('app/email-attachments/' . $filename)
);

Also you have to check if directories exists

06 Feb
7 months ago

petrit left a reply on Htmlspecialchars Error

Great!

petrit left a reply on Get Auth::user() With Its Associated Profile (1-1)

I am assuming that you have created new model called profile and that is related to user model one to one relationship. So, you should check if that relationship exist

auth()->user()->has('profile')->get();

Also check documentation https://laravel.com/docs/5.7/eloquent-relationships#querying-relationship-existence

27 Jan
7 months ago

petrit left a reply on PDF Generation

I would recommend Dompdf package for generating pdf. You can find it here at this link https://github.com/barryvdh/laravel-dompdf

11 Dec
9 months ago

petrit left a reply on Best Way To Dynamically Edit A Model

I would implement validation also, something like this

public function update(Request $request, Order $quote)
{
if($request->has('update_billing')){
    $attributes = $request->validate([
        'billing_address_1' => 'required',
        'billing_address_2' => 'required',
        'billing_city' => 'required',
        'billing_country' => 'required',
        'billing_state' => 'required',
        'billing_phone' => 'required',
    ]);

    $quote->update($attributes);
};
09 Dec
9 months ago

petrit left a reply on Laravel Show Nearest Products First ?

I think you should implement service like Google Maps or Open Street Map.

07 Dec
9 months ago

petrit left a reply on Prevent Forms From Working

You may use conditions on views in order prevent forms from acting normally. You may check if the user level is demo change action attribute from form. Also you may use middleware in order to prevent your controllers being executed from demo users.

petrit left a reply on Can I Use Eloquent's Count() With GroupBy()?

@talinon, @roborobok, this is much cleaner way than using DB::raw

Game::select('is_released')->get()->groupBy('is_released')->count();

petrit left a reply on Can I Use Eloquent's Count() With GroupBy()?

Game::all()->groupBy('is_released')->count();

petrit left a reply on How To Convert Controller Things To Blade View In Laravel

@foreach($vehicles as $vehicle)

@if($vehicle->categoryname != $cat)
{{ $cat }}<br><br>
@endif
{{ $vehicle->brandname }} <br>
@endforeach

petrit left a reply on Datepicker Duplicate ID

You have to set id to your inputs

...
<input type='text' name="date_debut[]" class="form-control" placeholder="Date debut" id="datetimepicker1"/>
...
06 Dec
9 months ago

petrit left a reply on Undefined Variable: Categories (View: E:\lara-test1\resources\views\posts\create.blade.php)

public function create()
    {
        $categories = Category::all(); 
        return view('posts.create')->withCategories($categories); 
    }

replace with

public function create()
    {
        $categories = Category::all(); 
        return view('posts.create')->with('categories'); 
    }

petrit left a reply on Many To Many WhereHasAll

If I am understanding correctly, you want to search with two tags (or more than two) into posts. And you want to select only the posts that are related to those tags?

petrit left a reply on UPGRADE TO LARAVEL 5.7 FROM 5.4

I think you should upgrade 5.4 to 5.5, than 5.5 to 5.6, than 5.6 to 5.7. All the time by following the upgraded guides https://laravel.com/docs/5.4/upgrade

petrit left a reply on Disable Updated_at Time Of Insert

Set the $timestamps property to false, and add manually created_at when creating and add manually updated_at when updating.

05 Dec
9 months ago

petrit left a reply on Changing The Register Link

Instead of using Auth::routes() you can use these routes

// Authentication Routes...
$this->get('login', 'Auth\[email protected]')->name('login');
$this->post('login', 'Auth\[email protected]');
$this->post('logout', 'Auth\[email protected]')->name('logout');

// Registration Routes...
$this->get('register', 'Auth\[email protected]')->name('register');
$this->post('register', 'Auth\[email protected]');

// Password Reset Routes...
$this->get('password/reset', 'Auth\[email protected]');
$this->post('password/email', 'Auth\[email protected]');
$this->get('password/reset/{token}', 'Auth\[email protected]');
$this->post('password/reset', 'Auth\[email protected]');
03 Dec
9 months ago

petrit left a reply on Problem Overriding Login Trait

I think firstly you have to logout the user that redirect to login page. But, you could use middlewares also.

02 Dec
9 months ago

petrit left a reply on Return Values For An Array Of Ids

This way you will get an array with desired column

$table= Table::whereIn('name', $myarray)->get()->pluck('ColA');

petrit left a reply on Return Values For An Array Of Ids

$ids = [1001, 1004]
$fruits= Table::whereIn('column', $ids)->get();
foreach($fruits as $fruit)
{
    //Code goes here
}
01 Dec
9 months ago

petrit left a reply on Storage:Link Not Working Properly

If you are using windows than you have to "run as administrator" the command line editor. Than enter the "vagrant up" and "vagrant ssh" and execute the command from there and it should work.

petrit started a new conversation Prevent App From Duplicate Requests

Sometimes we may come across to the situation where duplicate post requests can be stored into the database because of these user actions:

  1. If user clicks many times on the submit button,
  2. If API call take longer to complete execution and the user refresh the page

The question is how to prevent our application from storing duplicate post requests?

I am applying a solution for case one by disabling the submit button after a submit.

30 Nov
9 months ago

petrit left a reply on Multiple Things To One Query

...
$events->whereDate('end_date', '>=', date('Y-m-d'))->paginate(15);
...

petrit left a reply on Retrieving Intermediate Table Specific Columns

You are using many-to-many relationship between course table and user table. On you relationship you should specify which columns

...
public function courses()
{
    return $this->belongsToMany(Course::class)->withPivot('column1', 'column2');
}

than,

$user = App\User::find(1);

foreach ($user->courses as $role) {
    echo $role->pivot->column1;
}

https://laravel.com/docs/5.7/eloquent-relationships#many-to-many

29 Nov
9 months ago

petrit left a reply on Request Status Code 404 Not Found

Make sure that you have configured apache correctly. Refer to this https://www.howtoforge.com/tutorial/install-laravel-on-ubuntu-for-apache/

petrit left a reply on Array Validation Messages With Key

Try this

...
'unique' => 'The E-mail :attribute has already been taken.',
...

petrit left a reply on Array Validation Messages With Key

Validator::make($rows->toArray(), [
            '*.initials' => 'required|max:10',
            '*.first_name' => 'max:50',
            '*.prefixes' => 'max:10',
            '*.last_name' => 'required|max:50',
            '*.email' => 'required|email|unique:users,email'
        ], 
    [
        '*.email' => [
                'unique' => 'The E-mail address has already been taken.',
            ]
    ])->validate();

petrit left a reply on How To Convert Html To Pdf By DOM-PDF With Proper HTML Design

@VINUBANGS - It is related to your server resources. It is normal taking much longer time to load pdf view than loading only a view.

petrit left a reply on How To Convert Html To Pdf By DOM-PDF With Proper HTML Design

You design depends on your css style. Maybe defining setPaper will help a little

...
public function download($id)
{
    $showalumni = User::where('id',$id)->with('showcollege','showcourse')->first();
    return PDF::setPaper('a4', 'portrait')->loadView('Admin.showalumni', compact('showalumni'))->stream('invoice.pdf);
}

otherwise, refer to this link here https://github.com/dompdf/dompdf/wiki

petrit left a reply on Remote Database Configuration

@BOLDSTAR - Glad to hear that.

28 Nov
9 months ago

petrit left a reply on View Displays Success Message Twice

Probably you are declaring twice html on your view. Share your view file.

petrit left a reply on How Can I Have A Site Point To Another Directory In Homestead?

You may create a symbolic link to your local server

sudo ln -s /home/vagrant/code/dev/ /home/vagrant/code/mysite.dev/

than mytest.test/dev will link to /home/vagrant/code/dev/

petrit left a reply on How Can I Have A Site Point To Another Directory In Homestead?

On your Homestead.yaml

...
sites:
    - map: mysite.test
      to: /home/vagrant/Code/mysite
      
    - map: test.test
      to: /home/vagrant/Code/laravel-project/public

On you hosts file you add

...
192.168.10.10       mysite.test
192.168.10.10       test.test

and you will have two separated local websites (mysite.com and test.test)

25 Nov
9 months ago

petrit left a reply on Track How Many Users Online In Real Time?

@IANFAIN - Using this package you can implement google analytics data on your laravel project https://github.com/spatie/laravel-analytics

petrit left a reply on Track How Many Users Online In Real Time?

You may use Google Analytics to view online users in real time.

19 Nov
10 months ago

petrit left a reply on Strange Error With Laravel DB Query

I looks like you are missing a column called is_featured in your table called contents.

petrit left a reply on Workflow To Fetch Updates From Git To Laravel

GIT PULL will update your local files from git repository. But, you should always use git pull before changing your local files.

petrit left a reply on Email Verification

Also you should implement MustVerifyEmail contract on User model class

<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable implements MustVerifyEmail
{
...

petrit left a reply on Application Structure Suggestion

Based on your description than there should be three tables: classroom, group, course. And the relation between them: Course-Group (one to many), Group-Classroom (one to many)

petrit left a reply on Email Verification

Have you setup email configuration?

petrit left a reply on Email Verification

Your user table must contain an "email_verified_at" column to store the date and time that the email address was verified. When you execute php artisan make:auth laravel will generate all necessary views for verifying email. You should add this to the routes

Auth::routes(['verify' => true]);

And, place where verified users will enter

Route::get('profile', function () {
    // Only verified users may enter...
})->middleware('verified');

I am assuming that you have 5.7 version and your email is configured.