Sergiu17

Sergiu17

Chisinau

Member Since 1 Year Ago

Experience Points 229,390
Experience
Level
Lessons Completed 1333
Lessons
Completed
Best Reply Awards 142
Best Answer
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.

19 Jan
1 day ago

Sergiu17 left a reply on Is There Any Easy Methods To Using Ajax With Laravel?

https://github.com/axios/axios this library, it comes with default Laravel installation, check package.json file

15 Jan
5 days ago

Sergiu17 left a reply on Request Always Empty

Show your form

Sergiu17 left a reply on Link To Current Url But Change 1 Param

@timvandijck

request()->segments();

returns you an array of segments, in your case

request()->segments()[0] // would be 'en'
$segments = request()->segments();
$segments[0] = 'nl';

$url = implode('/', $segments);

return redirect($url);

You may need to tinker a little bit to get what you need

Sergiu17 left a reply on How To Add Laravel Project To Github?

Use HTTP, instead of SSH, when you did

git remote add origin

Choose HTTP Link, or setup you SSH, but is harder than HTTP

14 Jan
6 days ago

Sergiu17 left a reply on How To Use Laravel Localization On Database Fetched Records?

Given you have following structure of the database

id  key     en      ro      fr
--------------------------------------------------------
1   hello       Hello   Salut   Bonjour
// resources/lang/en/translation.php
<?php

return Lang::get()->pluck('key', 'en');
// resources/lang/fr/translation.php
<?php

return Lang::get()->pluck('key', 'fr');
// resources/lang/ro/translation.php
<?php

return Lang::get()->pluck('key', 'ro');

Every time you add a language - you add new column to languages

// usage
trans('translation.hello');
13 Jan
1 week ago
12 Jan
1 week ago

Sergiu17 left a reply on Factory Faker Unique() Across All Tests?

@dhermann Isn't id auto incremental column? and you should ever include id in that array, or I'm missing something?

Sergiu17 left a reply on Best Way For Exchange Data ?

If those components are inside your Laravel application - I'd use simple routs ( web.php )

If your Vue application is separate from your Laravel application - I'd go with api routs ( api.web )

And remember, there's no best way :) it depends on the situation

Sergiu17 left a reply on Create Best Relationship And Migration

@MDELSHAD - You're welcome, basically you don't need more relationships, you need more fields.

And if you add more functionality, for example Completed Courses, you may need to create one more relation between Users and Completed Courses

Sergiu17 left a reply on Create Best Relationship And Migration

@MDELSHAD - This is many to many relationship - https://laravel.com/docs/5.7/eloquent-relationships#many-to-many

1) User has many courses
1) Course has many users

> is it a table?

Yes, this is a pivot table

> And should I write like this?

Yes, but you need to add foreign keys

// Schema::create('course_user', function (Blueprint $table) { $table->integer('user_id'); $table->integer('course_id');

$table->foreign('user_id')->references('id')->on('users');
$table->foreign('course_id')->references('id')->on('courses');

});

Sergiu17 left a reply on Create Best Relationship And Migration

user
    - id
    - name

courses
    - id
    - name

course_user
    - user_id
    - course_id

chapters
    - name
    - course_id

videos
    - id
    - name
    - chapter_id
    - course_id ( unnecessary )

Something like this

11 Jan
1 week ago

Sergiu17 left a reply on Undefined Offset: 0

If you are trying to select all tasks for the project

Project::with('tasts')->get()

This is enough..

Project::with('tasks')->where('id','=',$project->tasks[0]->project_id)->get();

This query doesn't make any sens..

Sergiu17 left a reply on Object Of Class App\\Repository\\UserRepository Could Not Be Converted To String

$this->$userRepository

Unnecessary dollar sign

Sergiu17 left a reply on Laravel To How Much Can Online User Support?

I don't understand what are you trying to ask

how much can online user support?

Order number of online users.

What are you asking?

Sergiu17 left a reply on Npm Run Dev Issue

@pema Did you remove something from package.json file?

Sergiu17 left a reply on Doubt Works With {{ Csrf_field() }}, In Laravel 5.5

@VLAD_KASH - @csrf is available from 5.6 and up I guess

10 Jan
1 week ago

Sergiu17 left a reply on Using Phpunit/ Why Phpunit Removes All Data In My Database

@abduljakul-salsalani (crying) because no one writes tests on production database

Sergiu17 left a reply on Route Variables

Route::get('threads/{channel}/{thread}/replies', '[email protected]');
public function show(Channel $channel, Thread $thread)

// or
Route::get('threads/{channel_id}/{thread}/replies', '[email protected]');
public function show(Channel $channel_id, Thread $thread)

If you use Route Model Binding, your parameter from route should match with parameter from method

07 Jan
1 week ago

Sergiu17 left a reply on Call To Undefined Method App\User::notify()

Show your entire User.php file

06 Jan
2 weeks ago

Sergiu17 left a reply on How To Install Laravel Package On Cpanel

@mitismirza @musa11971 The easiest way would be to download composer.phar file and place it into the root of the project, then ssh into your server, and run

php composer.phar install vendor/package
// or
php composer.phar update

Sergiu17 left a reply on How To Install Laravel Package On Cpanel

Hi, after updating the composer.json file, you need to run composer update

Sergiu17 left a reply on Universal (database) GroupBy Formatted Date

@ARDF16 - Not sure if I understood you correctly, if so, then you can add a method to your model

class User extends Model
{
    public function setCreatedMonthAttribute()
    {
        $this->created_at
    }
}

// ....

$user = User::first();
$user->created_month;

Sergiu17 left a reply on Laravel Dosen't Redirect Request

@HSNTNGR - ``` "prefix" => app()->getLocale() ?? 'en';

This is how I'd do, if there is no `locale` - use `en` by default, after, create a controller to change language, and a middleware to redirect from `en` to `fr` for example

Sergiu17 left a reply on Universal (database) GroupBy Formatted Date

User::get()->groupBy(function($q) {
    return $q->created_at->format('M-Y);
});

Sergiu17 left a reply on Laravel Dosen't Redirect Request

@HSNTNGR - This code belongs to a middleware for sure. Could you show your routes?

05 Jan
2 weeks ago

Sergiu17 left a reply on Where Relationship Has More Than One Where Field Is True

Hi, like so?!

$allDiscounts = Discount::where('isVisible', true)->with(['discountcodes' => function($query) {
    $query->where('isUsed', 0);
}])->get();

Sergiu17 left a reply on Laravel Dosen't Redirect Request

Move this code into a middleware :)

Sergiu17 left a reply on How To Count Total Row Using Vue Js?

Show us some code ) how do you return data from controller to the view?!

Sergiu17 left a reply on How To Count Total Row Using Vue Js?

Which rows?

data.length // ?
03 Jan
2 weeks ago

Sergiu17 left a reply on Laravel Save Eloquent Two Tables With Relationship

@MYCLOUDCMS - Once again, depends on where do you save them, do you have separate table for txtInvoiceProduct[Unit]? Or to make it clear, where do you want to store txtInvoiceProduct[Unit] and txtInvoiceProduct[Gross] and any other similar fields?

Sergiu17 left a reply on Laravel Save Eloquent Two Tables With Relationship

@MYCLOUDCMS - Depends on how you save them, if you store them in a separate table, then you should loop over them like

foreach($request->txtInvoiceProductUnit as $unit) {
    $Invoiceitem = new Invoiceitem();
    $Invoiceitem->unite = $unit;
    $Invoiceitem->save();
}

If you save them in a single column, you could store as a JSON, or use implode() function from PHP

Sergiu17 left a reply on Laravel Save Eloquent Two Tables With Relationship

Could you do a dd($request->all())? And show us what you get? Would be easier to help you, and do you have relationships between Invoice Model and InvoiceItem Model?

Sergiu17 left a reply on Delete Stored Image When Update New One

<input type='file' name='image' />

// ...

public function update(Request $request, $id) {
    $user = User::findOrFail($id);

    if($request->has('image')) {
        if(file_exists('images/' . $user->avatar)) {
            unlink('images/' . $user->avatar);
        }

        $file = request('image');
        
        $user->avatar = $file->getClientOriginalName();
    }

    $user->save();
}

Basic example

02 Jan
2 weeks ago

Sergiu17 left a reply on Unable To Pass The Auth() Values To The Create Function.

Is the create function under auth middleware?

01 Jan
2 weeks ago

Sergiu17 left a reply on Request() Helper Vs Request $request?

Hi, there's no difference between them, they do exactly the same thing.

request() - is a helpers function ( wrapper function ) , open vendor/laravel/framework/src/Illuminate/Foundation/helpers.php - to see others

30 Dec
3 weeks ago

Sergiu17 left a reply on Desktop Icon

OK

Sergiu17 left a reply on Desktop Icon

You can't, this is no C# application

26 Dec
3 weeks ago

Sergiu17 left a reply on Where "code" = $request Returns Null

@PICKAB00 - No worries, sometimes this happens)

Sergiu17 left a reply on Where "code" = $request Returns Null

@PICKAB00 - and how do you know if it's passed null or not?

Sergiu17 left a reply on Where "code" = $request Returns Null

d($request->all()) shows the code

what does dd($request->code) show?