Sergiu17

Sergiu17

Member Since 2 Years Ago

Chisinau

Experience Points
310,450
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
1524
Lessons
Completed
Best Reply Awards
240
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 50
310,450 XP
Dec
06
3 days ago
Activity icon

Replied to Best Approach To Store Images / Articles

  1. If the article will have only one image, create one column in your articles table
  2. I'd store only the ID of the image

Anyway you will have to build the path to the file, either when you save image, or when you display it

Dec
05
4 days ago
Activity icon

Replied to Laravel 6 Verification Of Email - What To Do If User Is NOT Logged Anymore?

If the redirect route after login is /home and this route does not have verify middleware..it will not redirect you to verification link..


class LoginController extends Controller
{
    protected $redirectTo = '/home';
}
// ... 
Route::get('/home', '[email protected]')->name('home');

// ...
class HomeController extends Controller
{
    public function __construct()
    {
        $this->middleware(['auth', 'verify']);
    }
}
Dec
03
6 days ago
Activity icon

Replied to Laravel Search With Multiple Fields

@devsmote like so

$query = Appartment::query();

if(request()->has('location_id')) {
    $query->where('location_id', 'like', request('location_id');
}
if(request()->has('type_id')) {
    $query->where('type_id', 'like', request('type_id');
}
// and so on
// for fields like PRICE and METERS, you need to user orWhere()

$query->with('type', 'location', 'availability')->get()

also, if type_id comes from type relationship, then, you need to do some changes

Activity icon

Replied to Laravel Search With Multiple Fields

There's a cool function $request->has('field-name'), make use of it, if there's something in the request, then add a where clause

Dec
02
1 week ago
Activity icon

Replied to Unit Test Observer Model

@labib47 Hi, not sure what you are trying to do, but...

Let's clarify things a little bit, you want to test saved event on your Education model, saved event updates the form_education on the authenticated user.

What is isDirty method doing?

And I don't understand what those assertions doing, what do they have in common with saved event?

This is what I'd do probably

$user = factory(User::class)->create();

$this->actingAs($user); // login in the user.

// not sure why do you use Eduction::create in test, but fine for now.
Education::create(['user_id'=>$user->id , 'grade' => 'UK_FCH']); 

// saved Model event is fired, after ::create()


// this means that if $eduction->isDirty() returns true - then user is updated.
$this->assertTrue($user->fresh()->form_education);

// or, second case, when $education->isDirty() return false
$this->assertFalse($user->fresh()->form_education);
Activity icon

Replied to Route Model Binding

dd($organizatio); // n at the end?
Dec
01
1 week ago
Activity icon

Replied to Help With $this->actingAs($user)->post(...);

@trevorpan yes, it submits a post request to that route, it creates a new record, then you go to /dashboard and assert that you see company name.

P.S. don't forget about $this->actingAs($user)

Activity icon

Awarded Best Reply on Help With $this->actingAs($user)->post(...);

@trevorpan you don't event need the line with the factory on the Company class.. delete it.

// Logged in user
$user = factory(User::class)->create();

// Send a post request
$this->post('/dashboard/companies', ['name' => 'BidBird']);

// Make sure he sees the company name
$this->get('/dashboard')
    ->assertSee('BidBird');
Activity icon

Replied to Help With $this->actingAs($user)->post(...);

@trevorpan you don't event need the line with the factory on the Company class.. delete it.

// Logged in user
$user = factory(User::class)->create();

// Send a post request
$this->post('/dashboard/companies', ['name' => 'BidBird']);

// Make sure he sees the company name
$this->get('/dashboard')
    ->assertSee('BidBird');
Activity icon

Replied to Help With $this->actingAs($user)->post(...);

factory(Company::class)->create();
// method create, inserts one record in your database
// and when you say ->post()
// you create one more record, and you end up with two records..
public function user_can_add_a_company_to_their_profile(): void
{
    $user = factory(User::class)->create();

    $this->actingAs($user)
        ->post('/dashboard/companies', [
            'companyName' => 'BidBird',
        ]);

    $this->get('dashboard')
        ->assertSee('BidBird');
    
// this should be enough I think
Nov
29
1 week ago
Activity icon

Replied to JSON ARRAYS

You can't, every element inside an array has a key

Nov
22
2 weeks ago
Activity icon

Replied to PHPUnit Error

If you don't mind mister @markomeje , show your code please, sorry for disturbing.

Nov
21
2 weeks ago
Activity icon

Replied to Redirect To Specify Blade In Laravel Issue

@alinawaz

axios.post('/untyme/public/payPalPayment',formData)
.then(function (resp) {
    console.log(resp.data); // HERE YOU CAN SEE THE RESPONSE ( IN THE CONSOLE )
}).catch(function (resp) {
    console.log(resp); // if there are some errors
});
Activity icon

Replied to Redirect To Specify Blade In Laravel Issue

Here is the deal, when you send an AJAX Request, you can't return a view.

instead, return a JSON response

return [$site_url, $business_email, $package_title, $price, $credits, $custom];

or you may also define keys for each variable, like:

return [
    'site_url' => $site_url,
    'business_email' => $business_email
    // and so on
]
Nov
20
2 weeks ago
Activity icon

Awarded Best Reply on Multiple Images Gallery

@cosminandrei hmm, not sure it's null when your save to $images variable. ok

foreach($request->image_salons as $image) {
    // ...
}
Activity icon

Replied to Multiple Images Gallery

@cosminandrei hmm, not sure it's null when your save to $images variable. ok

foreach($request->image_salons as $image) {
    // ...
}
Activity icon

Replied to Multiple Images Gallery

OK, take small steps,

public function upload(Request $request) {
    dd($request->all());
}

If it doesn't include image_salons, check your HTML, check if it's the correct route

Activity icon

Replied to Multiple Images Gallery

@cosminandrei try to debug a little bit

$images = $request->input('image_salons');

dd($images); // Here should be all the selected images
Activity icon

Replied to Json 2 Table

what are your trying to achieve?

Activity icon

Replied to Multiple Images Gallery

@cosminandrei yep, add multiple attribute to your input

<input type="file" name="image_salons[]" class="form-control" multiple>

also you have to change your validation rules

$this->validate($request, [
    'image_salons' => 'required'
    'image_salons.*' => 'image|mimes:jpeg,png,jpg,gif,svg|max:2048'
]);
// this translates to:
// - image_salons filed is required
// - every item of image_salons array should be an image, max 2048 and jpeg, png, jpg, gif or svg format.

hope it helps, and will work without errors

Activity icon

Replied to Multiple Images Gallery

Hi @cosminandrei. first of all, your input should be an array

<!-- note square brackets after image_salons -->
<input type="file" name="image_salons[]" class="form-control">

then, exactly your code wrapped in a foreach loop

$images = $request->input('image_salons'); // array

foreach($images as $image) {
    $input['image_salons'] =
    time() . '.' . $image->getClientOriginalExtension();

    $image->move(public_path('images/salons'), $input['image_salons']);

    SalonsImageGallery::create($input);
}
Nov
19
2 weeks ago
Activity icon

Replied to Sort By Created_at

class Ticket extends Model
{
    public function activity()
    {
        return $this->hasMany(Activity::class)->orderBy('created_at', 'asc / desc');
    }
Nov
15
3 weeks ago
Activity icon

Replied to Save A Thread

Nov
12
3 weeks ago
Activity icon

Replied to Mock Nightmare

https://i.imgur.com/jSdSRxi.png

https://i.imgur.com/NsS7bOZ.png

There are two classes..

testing function from TryingMock class is called in other class, which you don't have ( second image )

Activity icon

Awarded Best Reply on Undefined Variable: Uid1

Second parameter to the send function is data

Mail::send(
    'mail.email',
    ['name' => 'PG-MANAGMENT', 'uid1' = $uid1],
    function($message) use ($uemail) {
        $message->to($uemail);
    }
Activity icon

Replied to Undefined Variable: Uid1

Second parameter to the send function is data

Mail::send(
    'mail.email',
    ['name' => 'PG-MANAGMENT', 'uid1' = $uid1],
    function($message) use ($uemail) {
        $message->to($uemail);
    }
Nov
11
4 weeks ago
Activity icon

Replied to General Error: 1364 Field 'first_name' Doesn't Have A Default Value

@masumluf I don't get it. You have your values in store method ( $request->all() )

And you want password before submitting? Where? In Vue? or?

Activity icon

Replied to General Error: 1364 Field 'first_name' Doesn't Have A Default Value

Probably because of the $fillable array in your model,

https://github.com/masumluf/ourschool/blob/master/app/Model/Student.php#L28

try to add first_name in array

Nov
08
1 month ago
Activity icon

Replied to Accessing .tag In PHP Variable

Hi, so what is $dropbox_file? an object or an array?

$dropbox_file->id   // object
$dropbox_file->name // object
$dropbox_file->size // object
$dropbox_file[".tag"] // array
Nov
07
1 month ago
Activity icon

Replied to How To Disable Throttle Or Rate Limiter ?

use Illuminate\Foundation\Testing\WithoutMiddleware;

class ExampleTestClass extends TestCase
{
    use WithoutMiddleware;

    public function exampleTestMethod()
    {
        $this->withoutMiddleware();

        // your test 
    }
}
Nov
06
1 month ago
Activity icon

Replied to Laravel Email Verfication Return Error When Try To Resgiter

change MAIL_DRIVER to log, or go to mailtrap.io, create an account, and update MAIL_USERNAME, MAIL_PASSWORD and MAIL_ENCRYPTION in your env file

Activity icon

Replied to Delete Button Not Functioning

What doesn't work? It doesn't submit? it doesn't delete?

Oct
31
1 month ago
Activity icon

Replied to Update Boolean Via Controller

Do you send any values to the controller?

public function active(Request $request, $id)
{
    dd($request->all()); // do you have something here?

    // Since your method is called active
    $cake->active = true;
    $cake->save();
}
Oct
25
1 month ago
Activity icon

Replied to Laravel And Vendor

https://getcomposer.org/doc/06-config.md#vendor-dir in composer.json file you can specify install directory

{
    "config": {
        "vendor-dir": "/var/www"
    }
}
Oct
23
1 month ago
Activity icon

Replied to List All Table In Database

Found on stackoverflow - https://stackoverflow.com/questions/33478988/how-to-fetch-the-tables-list-in-database-in-laravel-5-1

$tables = DB::select('SHOW TABLES');
foreach($tables as $table)
{
      echo $table->Tables_in_db_name;
}
foreach ($tables as $table) {
    foreach ($table as $key => $value)
        echo $value;
}
Activity icon

Replied to Eloquent : Return Only Some Attributes Instead Of All

public function participants()
{
    return $this->belongsToMany(User::class, 'participants_training')->select(['name']);
}

@nakov do you sleep dude? :D

Oct
22
1 month ago
Activity icon

Replied to Show Pdf File Before Download

@bekaskaki please note, that this will work only for you and people with settings to display PDFs, instead of download them.

Activity icon

Awarded Best Reply on Show Pdf File Before Download

I'm not quite sure, but this is about browser settings, I always can set to automatically to download or preview specific types of files in the browser

Firefox: https://i.imgur.com/1LQIEj5.png

Activity icon

Replied to Show Pdf File Before Download

I'm not quite sure, but this is about browser settings, I always can set to automatically to download or preview specific types of files in the browser

Firefox: https://i.imgur.com/1LQIEj5.png

Activity icon

Replied to ErrorException (E_WARNING) Count(): Parameter Must Be An Array Or An Object That Implements Countable

What do you want to count? admin::where('email',$request->email)->first();

First admin?

Use firstOrFail()

Oct
21
1 month ago
Activity icon

Replied to Reducing Laravel Queries (count())

use GROUP BY current_level

Oct
20
1 month ago
Activity icon

Awarded Best Reply on Learning Paths

Hi, https://laracasts.com/skills/php

  • The PHP Practitioner
  • Object-Oriented Bootcamp
  • PHP 7 Up and Running
  • What's New in PHP 7.1

and so one.

Lessons are ordered from basic to advanced.

Oct
17
1 month ago
Activity icon

Replied to Laravel Route Model Binding Is Not Working,

Route::verb('/url/{wildcard}', '[email protected]');

public function method(Model $wildcard) {}

Those two highlighted must match