ottoszika

ottoszika

Member Since 2 Years Ago

Experience Points 27,450
Experience
Level
Lessons Completed 230
Lessons
Completed
Best Reply Awards 8
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.

18 Mar
8 months ago

ottoszika left a reply on Service Provider Register Fix

Hello,

share method was removed since 5.4. Use:

$this->app->singleton('slug', function () {
    return new Slug;
});
13 Mar
9 months ago

ottoszika left a reply on Overriding A Method Implemented In A (used) Trait

Whenever you are "overriding" a trait method, it will take precedence over the trait's one. Also, you can extend the functionality (like calling the parent method and adding some extra stuffs) by aliasing:

trait RegistersUsers
{
    protected function registered(Request $request, $user)
    {
        echo 'Registered';   // Assuming this was originally in trait.
    }
}
class RegisterController
{
    use RegistersUsers {
        registered as traitRegistered;
    }

    protected function registered(Request $request, $user)
    {
        $this->traitRegistered();
        echo 'Welcome ' . $user->name;
    }
}

Note: Traits are not multiple inheritance. They are a code reuse mechanism, often called mixins in other languages.

ottoszika left a reply on GetRouteByKeyName Another Model Laravel

Hello,

You can't reference a field from another model, but you can create a route model binding in your RouteServiceProvider like this:

Route::bind('category', function ($value) {
    return optional(CategoriesTranslations::where('alias', $value)->first())->category;
});

Ensure you set up relationships correctly.

Now you can bind in your controller like this:

public function show(Categories $category) {
}

P.S.: Try naming your models singular. It's little bit confusing with plural names :)

06 Mar
9 months ago

ottoszika left a reply on How Can I Dynamically Generate "getExampleAttribute()" Functions In A Model Class?

Hi,

You can override the __call method of the model. Something like this:

protected $fields = [
    // Here you declare the fields you need
];

public function __call($method, $parameters) {
    if (preg_match('/get([^;]+?)Attribute$/', $method, $match)) {
        $property = Str::snake($match[1]);
        if (array_search($property, $this->fields) !== false) {
            return $this->getAttribute($property);
        }
    }
    return parent::__call($method, $parameters);
}
        
05 Mar
9 months ago

ottoszika left a reply on Aliases And Undefined Method In Facade

If you are using facades, the methods should be called statically (see Illuminate\Support\Facades\Facade how it works with it's __callStatic magic method to understand why).

Use WP::autenticate() in this case.

ottoszika left a reply on Laravel Failed To Open Stream: No Such File In Directory

Maybe it's cached in bootstrap/cache/config.php. Try: php artisan config:clear.

ottoszika left a reply on Laravel Failed To Open Stream: No Such File In Directory

I see you are using "file" as session driver. Your application is deployed on a Linux server, but you have a Windows-like path set. Please verify your config/session.php file. I think you hardcoded your storage path. Default value for path is:

...
'files' => storage_path('framework/sessions'),
...

ottoszika left a reply on Error

Laravel 5.6 requires php >= 7.1.5. The error is probably from the following line: public function __construct(?string $test) Nullable types are available only from PHP 7.1: http://php.net/manual/ro/migration71.new-features.php

01 Mar
9 months ago

ottoszika left a reply on NewQuery, ToBase, GetQuery

$model->where('prm_partner_id', 1)->toBase()->toSql(); $model->where('prm_partner_id', 1)->getQuery()->toSql(); The first will apply global query scopes, the second not. To test this quickly, you can use SoftDeletes trait in the model to see the difference.

$model->where('prm_partner_id', 1)->newQuery()->toSql(); The code above creates a new Builder based on the initial one. The same result is obtained with the following: $model->where('prm_partner_id', 1)->toSql();

02 Jun
1 year ago

ottoszika left a reply on Class Settings Not Found In Route.php

Type with FQN if you don't want to use it (App\Settings::settings()``)`. Also make sure your class is namespaced correctly (namesoace App;```).

ottoszika left a reply on VerifyCRSFToken Except On URL With Query Parameter

Try overriding the handle method from the base class and add some extra verifications there for your case.

21 Apr
1 year ago

ottoszika left a reply on How Can I Delete Records With The Checkbox?

Put on each row a checkbox with the name "users[]" and the user ID as value. On submitting the form, just take the array and prepare a whereIn query builder and call delete method on it (Hoping you will select only a few number of users, because the generated query will be as long as the selection array, otherwise just loop over each User instance).

public function destroyAll(Request $request)
{
    $selectedIds = $request->input('users');
    User::whereIn('id', $selectedIds)->delete();
}
15 Dec
2 years ago

ottoszika left a reply on Update Method Doesn't Save Data To Database

Are the fields present in the $fillable property of the Comment model?

06 Dec
2 years ago

ottoszika left a reply on I Want To Display My Page Numbers At Bottom In Laravel 5.3.

Where you linked the CSS? I don't see in your index.blade.php. If you linked in a master layout page, this page should extend that layout. https://laravel.com/docs/5.3/blade#extending-a-layout

ottoszika left a reply on I Want To Display My Page Numbers At Bottom In Laravel 5.3.

Laravel's default pagination presenter is based on Bootstrap. If that's all you have in index.blade.php, you should include the CSS.