Sergiu17

Sergiu17

Member Since 3 Years Ago

Chisinau

Experience Points
384,650
Total
Experience

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
1672
Lessons
Completed
Best Reply Awards
337
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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 50
384,650 XP
Aug
08
1 day ago
Activity icon

Replied to How To Code Date Time Booking System In Pure Php

Use DATETIME format for your column in your database.

And for PHP check documentation https://www.php.net/manual/en/datetime.format.php

$date = new DateTime('2000-01-01');
echo $date->format('Y-m-d H:i:s');
Aug
06
3 days ago
Activity icon

Awarded Best Reply on Database Update Not Update. It Reappeared

Hi, probably you are redirected back, because validation fails

@if ($errors->any())
    <div class="alert alert-danger">
        <ul>
            @foreach ($errors->all() as $error)
                <li>{{ $error }}</li>
            @endforeach
        </ul>
    </div>
@endif

or, make sure that $fillable array contains all the properties in Product model

protected $fillable = ['brand_id', 'sku', 'name' ... ];
Aug
05
4 days ago
Activity icon

Replied to Database Update Not Update. It Reappeared

Hi, probably you are redirected back, because validation fails

@if ($errors->any())
    <div class="alert alert-danger">
        <ul>
            @foreach ($errors->all() as $error)
                <li>{{ $error }}</li>
            @endforeach
        </ul>
    </div>
@endif

or, make sure that $fillable array contains all the properties in Product model

protected $fillable = ['brand_id', 'sku', 'name' ... ];
Activity icon

Replied to Laravel 7 - LoginController - Allow Only Users With "active=1"

@petrkaterinak the documentation's section from the link you posted is called Manually Authenticating Users, this means that you create a route by yourself and the controller too.

laravel/ui package uses AuthenticatesUsers trait, and yes, you have to overwrite the method if you want different behaviour

Activity icon

Replied to Restricting Page Access Before Submitting Other Page In Laravel

Route::post('/step/1', '[email protected]');
Route::post('/step/2', '[email protected]');
Route::post('/step/3', '[email protected]');

class RegisterStepsController
{
	public function first() {
		// store details from first step

		$user->level = 1;
		$user->save();
	}

	public function second(Request $request) {
		// less than one or you could do $request->user->level === 0
		// depends on what behaviour you want
		if($request->user->level < 1) {
			return 'Complete first step';
		}

		// store details from second step

		$user->level = 2;
		$user->save();
	}

	public function third(Request $request) {
		// $request->user->level === 1
		if($request->user->level < 2) {
			return 'Complete second step'
		}

		// store details from third step

		$user->level = 3;
		$user->save();
	}
}

@tarang19 something like this should get the job done

Activity icon

Awarded Best Reply on Restricting Page Access Before Submitting Other Page In Laravel

One flag in your database, status or level - by default will be 0

when user completes first step - you update status to 1

when user completes second step - you update status to 2

when user completes third step - you update status to 3

this would be the easiest option I guess

Activity icon

Replied to Restricting Page Access Before Submitting Other Page In Laravel

One flag in your database, status or level - by default will be 0

when user completes first step - you update status to 1

when user completes second step - you update status to 2

when user completes third step - you update status to 3

this would be the easiest option I guess

Activity icon

Replied to API Throttling

https://github.com/laravel/laravel/blob/master/app/Http/Kernel.php#L43

php artisan config:clear && php artisan route:clear

Aug
04
5 days ago
Activity icon

Awarded Best Reply on How To Display Unknown On The View Blade For Date_of_birth

public function getDateOfBirthAttribute($input)
{
   return $input ? Carbon::parse($input)->format(config('app.date_format')) : 'Unknown';
}
Activity icon

Replied to How To Display Unknown On The View Blade For Date_of_birth

public function getDateOfBirthAttribute($input)
{
   return $input ? Carbon::parse($input)->format(config('app.date_format')) : 'Unknown';
}
Activity icon

Awarded Best Reply on How Do I Change My Avatar In Laracasts Profile?

Emails should match, from laracasts and gravatar, and it takes few minutes to update

Activity icon

Replied to How Do I Change My Avatar In Laracasts Profile?

Emails should match, from laracasts and gravatar, and it takes few minutes to update

Aug
02
1 week ago
Activity icon

Replied to Get Percentage

$sum = Model::sum('votes');
$total = Model::count();

$avg = $sum / $total;
Activity icon

Awarded Best Reply on Multiple Image Upload

$photo->store() instead of $imageUniqueName->store()

Activity icon

Replied to Multiple Image Upload

$photo->store() instead of $imageUniqueName->store()

Activity icon

Replied to Custom Display Pagination Laravel 5.2

php artisan vendor:publish --tag=laravel-pagination

You could publish the views (copy them inside views folder`) and modify however you want

Activity icon

Replied to This Test Did Not Perform Any Assertions

@nickywan123 yes, it's wrong, if you use create - it create a new record, and right to the next line you send a post request to create another one..you will end up with two replies in your database.

let's write a test to check if authenticated user can leave a reply with create

$this->actingAs(factory('App\User')->create());

$thread = factory('App\Thread')->create();
$reply = factory('App\Reply')->create(); // we already have a reply in a database

$this->post($thread->path().'/replies', $reply->toArray());

$this->assertDatabaseCount('replies', 1); // this explains why you need to use make
Activity icon

Replied to How To Store Array In DB: Array To String Conversion Error!

User json datatype for value column, and in your settings model cast it to array

class Settings extends Model
{
    protected $casts = [
        'value' => 'array',
    ];
}
Aug
01
1 week ago
Activity icon

Replied to After FTP To Server, Still Reference To Local Path

Hi, did you try to clear the cache and config?

Activity icon

Replied to This Test Did Not Perform Any Assertions

You could assert that you are redirect to /login, also, use make() instead of create() to the reply, and assert that database has no records in replies table

$thread = factory('App\Thread')->create();
$reply = factory('App\Reply')->make();

$this->post($thread->path().'/replies', $reply->toArray());

$this->assertDatabaseMissing('replies', $reply->toArray());
Activity icon

Replied to Laravel Validate Array Of Images

name="productImage[]" // <---- add []

add square brackets to the name of the input, then 'productImage.*' will work

Jul
30
1 week ago
Activity icon

Awarded Best Reply on Accessing Relationships From Another Relationship, How?

User::with('ads.category')->get()
Activity icon

Replied to Accessing Relationships From Another Relationship, How?

User::with('ads.category')->get()
Activity icon

Replied to Call To Undefined Method Illuminate\Database\Query\Builder::createToken()

Did you add HasApiTokens trait to your User model?

class User extends Authenticatable
{
    use HasApiTokens;
}
Activity icon

Replied to Undefined Property: HasMany::$id

Hi, what do you get if you dd($invoice->payments()->latest('date')->first()) ?

Jul
29
1 week ago
Activity icon

Awarded Best Reply on Laravel 5.8 Redirect()->route('name') Not Working

try to return

return $this->loginAndRedirect($user);
Activity icon

Replied to Laravel 5.8 Redirect()->route('name') Not Working

try to return

return $this->loginAndRedirect($user);
Jul
28
1 week ago
Activity icon

Replied to Seeding For PEST Test

@tobiass do you have DepartmentSeeder class inside database/seeds/ folder?

Activity icon

Replied to Resources / Books For Learning MySQL

I recommend you the official documentation - https://dev.mysql.com/doc/

Activity icon

Replied to Undefined Variable: Data

There's an if statement, $data may be never initialized

$data = []; // initialize it as empty array
if () {
Jul
26
2 weeks ago
Activity icon

Awarded Best Reply on How To Keep Passing The Same Data To Navbar On Blade Without Repeating It?

Hi, https://laravel.com/docs/7.x/views#view-composers

View::composer('*', function ($view) {
    $view->with('data', Model::get());
});
Activity icon

Replied to How To Keep Passing The Same Data To Navbar On Blade Without Repeating It?

Hi, https://laravel.com/docs/7.x/views#view-composers

View::composer('*', function ($view) {
    $view->with('data', Model::get());
});
Jul
23
2 weeks ago
Activity icon

Awarded Best Reply on Get_class() Expects Parameter 1 To Be Object, Null Given (Yajra Datatable)

$data = Lead::find($request->leadid)->notes;

dd($data); // this should return null

you could add a simple if statement

$data = Lead::find($request->leadid)->notes;

if( $data === null ) { return 'No data available'; }

return Datatables::of($data) ...
Activity icon

Replied to Get_class() Expects Parameter 1 To Be Object, Null Given (Yajra Datatable)

$data = Lead::find($request->leadid)->notes;

dd($data); // this should return null

you could add a simple if statement

$data = Lead::find($request->leadid)->notes;

if( $data === null ) { return 'No data available'; }

return Datatables::of($data) ...
Activity icon

Awarded Best Reply on Seeding For PEST Test

Looks like you have to import DealsTestSeeder class

use App\Models\Deal;
use Illuminate\Support\Facades\Storage;
use Illuminate\Database\Seeder\DealsTestSeeder; // <=== this line

test('report returns deals of status 8', function() {
    $this->seed(DealsTestSeeder::class);
Activity icon

Replied to Seeding For PEST Test

Looks like you have to import DealsTestSeeder class

use App\Models\Deal;
use Illuminate\Support\Facades\Storage;
use Illuminate\Database\Seeder\DealsTestSeeder; // <=== this line

test('report returns deals of status 8', function() {
    $this->seed(DealsTestSeeder::class);
Jul
17
3 weeks ago
Activity icon

Replied to HOw Can I Write Extensible Code In PHP

@deep88 I may misunderstood something, looks like first answer is more suitable

Activity icon

Replied to HOw Can I Write Extensible Code In PHP

Create a helper file, inside app/Helpers/helpers.php, write your functions, then load the file in composer.json

{
    "autoload": {
        "files": ["app/Helpers/helpers.php"]
    }
}
Jul
12
4 weeks ago
Activity icon

Replied to 1 User Can Follow Only 1 User

$table->primary('user_id','following_user_id'); - this is wrong, they shouldn't be primary

Activity icon

Replied to How To Get Related Data Of A Collection (lumen) ?

hi, try this

$folder = Folder::with('medias')->whereIn('id',  $relatedFolder)->get();
Jul
10
4 weeks ago
Activity icon

Replied to Laravel Email Verification Process Throw Error

You send a GET request to a POST Route, change it to POST

Activity icon

Awarded Best Reply on Can't Call Method From Controller.

$order = Order::where('id', $id)->first();

// or

$order = Order::findOrFail($id);

Order::where('id', $id); - this, returns a Eloquent Builder Instance, you can't access methods from any model on it

Activity icon

Replied to Can't Call Method From Controller.

$order = Order::where('id', $id)->first();

// or

$order = Order::findOrFail($id);

Order::where('id', $id); - this, returns a Eloquent Builder Instance, you can't access methods from any model on it

Jul
07
1 month ago
Activity icon

Awarded Best Reply on How Can I Get Access To Uploaded File?

https://laravel.com/docs/7.x/filesystem#the-public-disk

run php artisan storage:link, then

href="{{ asset($item->voucher) }}"
Jul
06
1 month ago
Activity icon

Replied to How Can I Get Access To Uploaded File?

https://laravel.com/docs/7.x/filesystem#the-public-disk

run php artisan storage:link, then

href="{{ asset($item->voucher) }}"
Jul
04
1 month ago
Activity icon

Replied to Field 'project_id' Doesn't Have A Default Value | Pass Variable To My Custom Trait

Hi, probably you should add project_id to the fillable array inside Material model

Activity icon

Replied to Getting All Items From Model String

Hi,

(new $resource->model)->all();