thoasty

thoasty

Member Since 2 Years Ago

Experience Points 10,300
Experience Level 3

4,700 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 2
Lessons
Completed
Best Reply Awards 17
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.

10 Apr
4 months ago

thoasty left a reply on To Show Statistics (percentage), Better To Work With Queries Or To Work On Collection ?

You might be looking for the wherePivot() method:

$counted = $training->users()->wherePivot('status', 1)->count();
$percentage = ($counted / $training->users()->count()) * 100;

Does that work? Greetings

05 Apr
4 months ago

thoasty left a reply on Setting GetRouteKeyName If A Condition Is Met

You may also want to look at explicit binding, because laravel also needs to know how to load your resource, if you load it with route model bindings:

https://laravel.com/docs/5.8/routing#route-model-binding

thoasty left a reply on Setting GetRouteKeyName If A Condition Is Met

Given you know what youre doing, this should help.

public function getRouteKeyName()
    {
    // if the user has set a url name, set it as the key name
        if ($this->link_name !== null) {
            return 'link_name';
        }
    // otherwise, return default
    return 'id';
    }
04 Mar
5 months ago

thoasty left a reply on Nova: How Do I Check Whether The User Is Inside The Admin Panel?

request()->is('nova/*')

Should be reliable though.

01 Mar
5 months ago

thoasty left a reply on Creating A Unique Access Key

You might either use laravel signed urls: https://laravel.com/docs/5.8/urls#signed-urls

Or look at the vinkla/hashids package: https://github.com/vinkla/laravel-hashids

28 Feb
5 months ago

thoasty left a reply on Cache Result Of Accessor On Model?

It really depends on your usecase, and it all just transfers the same logic to another class, but please share your thoughts on this:

class Series {
    public $_presenter;

    public function presenter() {
        return $this->_presenter ?? $this->_presenter = new SeriesPresenter($this);
    }

    public function getSequenceAttribute() {
        return $this->presenter()->sequence();
    }
}
class SeriesPresenter {
    public $model;

    public function __construct($model) {
        $this->model = $model;
    }

    public $sequence;

    public function sequence() {
        if (isset($this->sequence)) {
            return $this->sequence;
        }

        // work with $this->model to generate the value and return it
    }
}

thoasty left a reply on Queue:work Only Works If I Specify The Name

Wasnt sure either.

But im pretty sure you could at least set multiple queue names:

--queue=foo,bar,theName

That * might not be implemented because there is no sense having named queues but only one worker on all names.

thoasty left a reply on Queue:work Only Works If I Specify The Name

What about --queue=* ?

thoasty left a reply on Laravel 5.5: "Symfony\Component\HttpFoundation\Request::setTrustedHeaderName()" Method Is Deprecated

Laravel 5.5 seems to come with that error out of the box, according to this github issue: https://github.com/fideloper/TrustedProxy/issues/83

You might want to create an issue at https://github.com/laravel/framework/issues as Laravel 5.5 is LTS which means bug fixes for 2 years (being released on 2017-08-30)

thoasty left a reply on Cache Result Of Accessor On Model?

You could add another abstraction layer, like a "Presentable" trait and a "Presenter" class for each model class, that handles attributes that should be computed and cached.

thoasty left a reply on Nova Produce "too Much" Queries

You are either looking for eager loading, which would only make it 1 additional query: https://nova.laravel.com/docs/1.0/resources/#eager-loading

Or you except the relation with

BelongsTo::make('Leader','worker','App\Nova\Worker')->hideFromIndex(),

So it wont be loaded on the index.

thoasty left a reply on Can't Write Image Data To Path

Use "Storage::path" instead of "Storage::url"

Url is the public url, path is the actual directory on your server.

thoasty left a reply on Service Provider Routes Not Working

You will probably need the whole "web" middleware group, because its middlewares are also responsible for starting the session and other stuff.

Look at

app/Providers/RouteServiceProvider.php at the mapWebRoutes() method

and at app/Http/Kernel.php

to get a better understanding.

thoasty left a reply on Call Nova::routes() Before My App's

The order of your service providers in the config/app.php is the order they are registered / booted.

So you just need to put your nova service provider before the App\Providers\RouteServiceProvider

19 Dec
7 months ago

thoasty left a reply on Timestamp Conversion Exception With Carbon

Use the function Carbon::createFromTimestamp('1544590366');

Edit: 2 slow

18 Dec
8 months ago

thoasty left a reply on Laravel Blade | Hide If DB Data Doesn't Exists

Look at the forelse statement:

https://laravel.com/docs/5.7/blade#loops

@forelse ($users as $user)
    <li>{{ $user->name }}</li>
@empty
    <p>No users</p>
@endforelse
14 Dec
8 months ago

thoasty left a reply on Cannot Add Foreign Key Constraint

Seems to be an issue of export, rather than import. You might want to export the database in another tool that can handle the order.

thoasty left a reply on Getting Empty ID After Running $model->save()

And what does it say for "auto-increment" under the "table info" tab?

thoasty left a reply on Paginate A Database's Complete Results?

@UCCDEV - Maybe you should look at the pagination feature again:

https://laravel.com/docs/5.7/pagination

Using paginate you wont need manual skip and take and it doesnt load all of the 100k entries from the database, but only the 50...

thoasty left a reply on Getting Empty ID After Running $model->save()

@SLOVENIANGOONER - Im not talking about your migration but whats actually on the database. Can you take a screenshot of your structure, using any usual db inspector?

thoasty left a reply on Multidimensional Array From Vue To Laravel

That error might be coming from your validation rules, as you are not validating reading.*, but reading.*.*

thoasty left a reply on Multidimensional Array From Vue To Laravel

Really depends on your implementation but for example you could use (item, index) inside your v-for to get the index of the current item:

v-for="(item, index) in items"

thoasty left a reply on Getting Empty ID After Running $model->save()

Did you look at the database of the faulty entry with a db inspector? What does it say for auto_increment after you inserted an entry? Did you go sure your structure has auto_increment and PRIMARY key on the id?

thoasty left a reply on Multidimensional Array From Vue To Laravel

Because there is only 1 reading_type[] for every 3 reading[]

So this fails when looping through reading[$i]:

$reading->meter_type    = $types[$i];

Suggestion: insert defined indexes with vue, like this:

<select name="reading_type[0]" class="form-control">
    <option value="">Please Select</option>
    <option v-for="(type, index) in reading_type" 
            :value="type.tags"
            :key="type.index" 
            :id="type.id"
    >
        {{ type.value }}
    </option>
</select>
<div class="row mt-2">
    <div class="col">
        <label>Gas Reading</label>
        <input type="number" name="reading[0][0]" class="form-control">

        <label>Water Reading</label>
        <input type="text" name="reading[0][1]" class="form-control">

        <label>Electric Reading</label>
        <input type="number" name="reading[0][2]" class="form-control">
    </div>
    <div class="col">
        <label>Reading Date</label>
        <input type="date" class="form-control" name="reading_date[0][0]">

        <label>Reading Date</label>
        <input type="date" class="form-control" name="reading_date[0][1]">

        <label>Reading Date</label>
        <input type="date" class="form-control" name="reading_date[0][2]">
    </div>
</div>

thoasty left a reply on Running Laravel Passport Install On Production Server

@zion Could you please stop giving bad advice / spamming?

He already said that he was aware of composer install and that this would run on every deploy in his configuration, which is not needed for passport install.

@johnnoblestone As per the official documentation you should run migrate before install. So i would still recommend to put the command at the end of the last passport migration file (after publishing them to your codebase).

thoasty left a reply on Multidimensional Array From Vue To Laravel

for($i = 0; $i < $readings; $i++){

should at least be:

for($i = 0; $i < count($readings); $i++){

thoasty left a reply on Paginate A Database's Complete Results?

I know of the "->paginate(num)" extension I can add to my DB::table, like so instead of 'get':

only load, say, 50 at a time, and hitting the 'next' or 'previous' button will get the next batch of 50 after that

Thats exactly what paginate() (instead of get()) does.

thoasty left a reply on Running Laravel Passport Install On Production Server

So what do you think could be wrong about using a migration?

thoasty left a reply on Many Users Belong To One Team Which Belongs To One Project - Relationship Problems

"..as each user is attached to its own team object rather than 1 team object having many users related."

So whats the point of this? You will need a pivot table between Team and User to have more than 1 User attached to a team. See many to many relations for this: https://laravel.com/docs/5.7/eloquent-relationships#many-to-many

thoasty left a reply on How Best To Insert Data Into A Production Database?

You technically could use a migration.

See also:

Eloquent::unguard();

for allowing mass fill.

thoasty left a reply on Many Users Belong To One Team Which Belongs To One Project - Relationship Problems

What is your database structure for these models?

11 Oct
10 months ago

thoasty left a reply on Chuck Vs Pagination! Memory Usage

These methods have a different usecase. I assume you know how paginate works.

But "chunk" retrieves not only 15 entries, but all entries in "packets" of 15 entries. So your ram only loads 15 entries at the same time. But in the end, it will have loaded all entries of the query.

thoasty left a reply on Fetch Error Message Generated By File Upload Validator

What are your validation rules?

28 Aug
11 months ago

thoasty left a reply on Laravel Update Without Passing ID

As long as you dont use get(), it will only stay a query and not respect model methods / fillable.

Try

Ticket::where('ticket_number', $posted_ticket_number)->get()->update(array_merge($request->all(), ['picker_start_time' => Carbon::now()]));

And then control with the $fillable attribute, which of the model attributes are actually fillable by user input.

25 Jul
1 year ago

thoasty left a reply on Pagionate Not Showing Link

Shouldnt it be

{{ $subscriber->articles->links() }}

?

thoasty left a reply on Strange Pluralisation Behavior For Route::resource

I am assuming you are using Route::resource('lens', ...). Did you try with Route::resource('lenses', ...) ?

thoasty left a reply on Cloned Project From Git Only Works When All Files Are Inside Vendor/laravel/laravel Map

Check your /vendor/composer/autoload_classmap.php.

There you will find all classes that are included for autoloading. Try composer dump-autoload to regerenate the autoloading.

29 Jun
1 year ago

thoasty left a reply on Dynamic Fields Should Not Have Same Value

You seem to have made a couple of different mistakes then. You should check the rest of your code.

thoasty left a reply on Redirect User To A Specific Page If He Acesses A Conference With Id That Dont Exist

What do you mean with "stays available"? In else, $conference is null..

thoasty left a reply on Redirect User To A Specific Page If He Acesses A Conference With Id That Dont Exist

if ($conference = Conference::find($id)) {
 // exists
}
else {
 // does not exist
}

thoasty left a reply on Dynamic Fields Should Not Have Same Value

You might want to

Log::info($request->all())

to see if the validation really is the issue.

thoasty left a reply on How Can I Limit Unsigned Integer Of Blueprint Object To Only Have At Maximum 10 Numbers?

Try:

$table->addColumn('integer', 'something_else', ['unsigned' => true, 'length' => 10])

Cheers

thoasty left a reply on Dynamic Fields Should Not Have Same Value

Look at the "different" validation rule:

https://laravel.com/docs/5.6/validation#rule-different

Cheers

Edit: Or you might need the "distinct" rule:

https://laravel.com/docs/5.6/validation#rule-distinct

26 Feb
1 year ago

thoasty left a reply on Event Firing Problem (or Just Trying To Place A Cookie On A Page)

Use

return redirect()->with(array $data);
20 Feb
1 year ago

thoasty left a reply on API And Access Permission In Package

Give the user a special flag (like is_admin) and use a middleware on the routes you want to protect.

thoasty left a reply on Does Alias Work Only Work In View Templates?

Use \ViforiaApi (with a preceding )

(The answer to your question is no; they do not only work in views)

thoasty left a reply on Select Box With First Option Empty

Use ->toArray() after pluck(), because pluck returns another Collection.

$campaignLists = ['' => 'Select Campaign'] + Campaigns::where('c_status', '1')->pluck('c_campaign_name', 'c_id')->toArray();