petrit

petrit

Member Since 4 Years Ago

Prishtina

Experience Points 46,840
Experience Level 10

3,160 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 367
Lessons
Completed
Best Reply Awards 24
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.

06 Feb
1 month 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 this documentation https://laravel.com/docs/5.7/eloquent-relationships#querying-relationship-existence

27 Jan
1 month 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
3 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
3 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
3 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
3 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
3 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
3 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
3 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]
Table::whereIn('column', $ids)->get();
01 Dec
3 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
3 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
3 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, take refer to thir link here https://github.com/dompdf/dompdf/wiki

petrit left a reply on Remote Database Configuration

@BOLDSTAR - Glad to hear that.

28 Nov
3 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 created 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
3 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
4 months ago

petrit left a reply on Strange Error With Eloquent

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.

18 Nov
4 months ago

petrit left a reply on How To Upload And Show CSV File Data Into Laravel ?

    $file = Storage::get('file.csv');
        while ( ($line= fgetcsv($file, 1000, ",")) !==FALSE )
        {
             //$name = $line[0];
             //store data to database,...
        }

petrit left a reply on Multiple Customers Multiple Users - Separating Data Through Eloquent

I think you should use Gate class or Policies in order to give desired authorization to each user.

Here are two videos related to authorization https://laracasts.com/series/laravel-from-scratch-2018/episodes/26 https://laracasts.com/series/laravel-from-scratch-2018/episodes/27

Also here is a documentation https://laravel.com/docs/5.7/authorization

petrit left a reply on I Can't See My Images In My Admin Panel

@SLOWHAND - Yes sure,

<img src="/training-images/{{ $training->thumbnail }}">

petrit left a reply on I Can't See My Images In My Admin Panel

I am not sure how did you store your images, but I guess this will work

<img src="/{{ $training->thumbnail }}">

petrit left a reply on I Can't See My Images In My Admin Panel

How is defined the image path from the view? Or, the image should be displayed when adding this into the view

<img src="/training-images/medicine.jpg">

petrit left a reply on JQuery Each Onclick Not Working Well

The id must be unique for each html element. Having more elements with the same id is not valid html.

petrit left a reply on I Can't See My Images In My Admin Panel

You need a slash also in the beginning in order to create a full url

...
$training->thumbnail = "/training-images/".$filename;
...