Sergiu17

Sergiu17

Member Since 2 Years Ago

Chisinau

Experience Points 281,850
Experience Level 50

0 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 1431
Lessons
Completed
Best Reply Awards 210
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.

12 Jul
3 days ago

Sergiu17 left a reply on Liskov Substitution Principle

the internet is full of examples, spend 5 minutes to watch this video https://www.youtube.com/watch?v=Mmy1EUKC_iE

Sergiu17 left a reply on Liskov Substitution Principle

Response of purchase method from all classes should be the same, otherwise the principle is violated.

I'll try to explain, but obviously in my example is not where to use Liskov Substitution Principle

Let's imagine from start your shop had only PhysicalBook, after every purchase, the purchase method return to the frontend and response with 3 keys: \

  • status http status \
  • message to display to the user \
  • bookId to show the user link to the book he/she just bought.
{
    'status': 200,
    'message': 'Success',
    'bookId': 1
}

Now you introduce DownloadableBook, and in purchase you return only 2 keys\

  • status http status \
  • message to display to the user
{
    'status': 200,
    'message': 'Success',
}

and here is the violation, link to the book will be broken in frontend, the API is different. Hope this helps.

Sergiu17 left a reply on Using FirstOrCreate On Relationship Cause Error

the problem is not in firstOrCreate, firstOrCreate works with tags table, but error is caused when you try to insert into thread_tag table.

probably you need to do one more check

if $this->tags already contain the tag
    then return
else
    attach tag

Sergiu17 left a reply on Using FirstOrCreate On Relationship Cause Error

UNIQUE constraint failed

You already have and record with thread_id = 1 and tag_id = 1

Sergiu17 left a reply on Can I Define Dependency Injection In Any Class?

Can you be more specific?

11 Jul
4 days ago

Sergiu17 left a reply on Getting Form Submitted Continuously. I Want Form Submitted Only Once On Page Load

OK, as I understood.

// page loads
// form is submitted
// redirect back

// page loads
// form is submitted again
// redirect back

// infinite loop

Sending an AJAX Request would solve your problem

Sergiu17 left a reply on Getting Form Submitted Continuously. I Want Form Submitted Only Once On Page Load

Take the basics, learn about document.onload ( you don't need to submit form on this event )

Take a look here - https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_form_submit

Sergiu17 left a reply on Permanently Remove Certain Migrations

Open migrations table from your database, and you could manually delete records that correspond to your migrations' name

Sergiu17 left a reply on Undefined Variable: Products For PDF

PDF::loadView('admin.pdf.product-pdf', compact('products'));
// or
PDF::loadView('admin.pdf.product-pdf', $products);
10 Jul
5 days ago
09 Jul
6 days ago

Sergiu17 left a reply on Button Not Responding On Update

@method('PATCH')

Route::post('/montage/edit/{id}','[email protected]');

Two different HTTP request methods

Sergiu17 left a reply on Gulp Fails At Building Files

at least, show your config file )

08 Jul
1 week ago

Sergiu17 left a reply on Undefined Offset: 0 / WAMP W10 L5.8.27

dd kills the script, it stand from var_dump and die

Sergiu17 left a reply on Undefined Offset: 0 / WAMP W10 L5.8.27

@foreach ($projects as $project)
    {{ dd($project['image'][0]->filename) }} // script stops here.
@endforeach

what if second project doesn't have ['image'][0]?

06 Jul
1 week ago

Sergiu17 left a reply on Problems To Modify Table Attribute In Migrations, Laravel 5.5

create new migration

php artisan make:migration remove_unique_key --table=users
    public function up()
    {
        Schema::table('users', function (Blueprint $table) {
            $table->dropUnique('users_email_unique');
        });
    }
php artisan migrate

Sergiu17 left a reply on Problems To Modify Table Attribute In Migrations, Laravel 5.5

$table->dropUnique('users_email_unique');

https://laravel.com/docs/5.8/migrations Dropping Indexes Section

03 Jul
1 week ago
02 Jul
1 week ago

Sergiu17 left a reply on New Controller For Each Page

I think that one controller and one method is enough. Make the route and method dynamic.

I'm assuming you have Category and Game Models, and relationship between them.

Route::get('/categories/{category}', '[email protected]');

public function show(Category $category) {
    return $category->games;
}

basic example

01 Jul
2 weeks ago

Sergiu17 left a reply on How To Retrieve Filtered Table Result

Hi, you almost did

App\RiskAssessment::where(client_id, 2)->get();

add ->get() at the end

28 Jun
2 weeks ago

Sergiu17 left a reply on I Want To Show Delete Button Only To Its Post Owner In Vuejs

@RAVIAWASTI - send auth user id as a prop to your component

<post user-id="{{ auth()->id }}"></post>
props: ['userId'],
<a v-if="userId == post.user_id">Delete</a>

Sergiu17 left a reply on I Want To Show Delete Button Only To Its Post Owner In Vuejs

@RAVIAWASTI - Is this code inside blade file? or you use components?

Sergiu17 left a reply on I Want To Show Delete Button Only To Its Post Owner In Vuejs

https://vuejs.org/v2/guide/conditional.html

You need to have access to user-id and access to post-user-id

<a v-if="user.id == post.user_id">Delete</a>
25 Jun
2 weeks ago

Sergiu17 left a reply on How To Count From An Column?

You probably need something like this:

$categories = App\Category::withCount('events')->get();\
class Category extends Model
{
    public function events()
    {
        return $this->hasMany(Event::class);
    }
}

class Event extends Model
{
    public function category()
    {
        return $this->belongsTo(Category::class);
    }
}

Event belongs to Category Category has many Events

Sergiu17 left a reply on How To Count Rows In Database?

@ANDREIXFR - like so

$events = Event::count();

Sergiu17 left a reply on How To Count Rows In Database?

Model::count();
24 Jun
3 weeks ago

Sergiu17 left a reply on Custom Authentication

https://github.com/laravel/framework/blob/5.8/src/Illuminate/Auth/Middleware/EnsureEmailIsVerified.php

Create your own middleware base on one above. Adjust it a little bit, and you are good to go

Sergiu17 left a reply on Reactjs And Laravel API. Axios Returns 401 (Unauthorized)

@inemesis247

I thought that the code in my bootstrap.js is adding the token to any axios request.

This is other story - https://laravel.com/docs/5.8/csrf

Now, read this article - https://pineco.de/laravel-api-auth-with-tokens/

You have to add one more token, for authorization.

23 Jun
3 weeks ago

Sergiu17 left a reply on Reactjs And Laravel API. Axios Returns 401 (Unauthorized)

Since your route is under auth:api middleware, you have to pass token to the request, https://laravel.com/docs/5.8/api-authentication#passing-tokens-in-requests

20 Jun
3 weeks ago

Sergiu17 left a reply on Form POST Not Working

Show your code from controller