Spillmester

Spillmester

Member Since 3 Years Ago

Experience Points 25,110
Experience Level 6

4,890 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 243
Lessons
Completed
Best Reply Awards 1
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.

11 Jan
1 year ago

Spillmester left a reply on Vue/Laravel Stops Form Submission

blade file https://pastebin.com/BYcwmtDJ

Rest is just standard new laravel installation with auth enabled.

Doing what is suggested here works https://stackoverflow.com/questions/45996657/submit-a-form-in-vue-how-do-i-reference-the-form-element

But was hoping there is a way to not have vue override default behavior unless I ask it to.

10 Jan
1 year ago

Spillmester left a reply on Vue/Laravel Stops Form Submission

I use laravel collectives form generetion. Here is a link to the generated page

https://pastebin.com/K5gi0Ng0

Spillmester left a reply on Handling Large Dataset (1000+) In VueJS

lazy loading for the win on this

the search field could send search request to the backend. DataTables.net does this pretty seamlessly (jQuery) but right tool for the job

Spillmester started a new conversation Vue/Laravel Stops Form Submission

When using the default layout/blade templates in a new laravel 5.5, forms does not submit unless I remove vue from app.js

How can I enable default form behavior? And still use vue, as I thought I would start looking into vue

Spillmester left a reply on How To Use Vue In Laravel Blade?

Is that your full blade file?

23 May
2 years ago

Spillmester left a reply on JSON Casts Not Working(?)

I think I found the solution. When storing in database I have to use a new variable. And not the json string directly.

´´´php $json = json_decode($apiQuery); // does not work $apiQuery = json_decode($apiQuery);

        //echo $apiQuery;
        $call = MarketAPICall::create([
            'method' => $method,
            'pair' => $pair,
            'market' => 'marketname',
            'res' => $json, //json_encode($apiQuery), will not work
            'timestamp' => time()
        ]);

´´´

Spillmester left a reply on JSON Casts Not Working(?)

I noticed that in the databse the json gets stored like this:

"{/"status": /"error/", /"message/": "some message/"}" (forward slashes are backlsashes, but got stripped by forum)

But if I edit it to

{"status": "error", "message": "some message"}

It seems to work. Any suggestion on how I can insert insert it properly?

22 May
2 years ago

Spillmester left a reply on JSON Casts Not Working(?)

Same result.

19 May
2 years ago

Spillmester left a reply on JSON Casts Not Working(?)

Also tried this. But unless return json_decode directly I just get a string.

   private $resultJSON = null;


    public function getResultAttribute($value){
        if($this->resultJSON == null){
            //return json_decode($value);
            $this->resultJSON = json_decode($value);
            //dd($this->resultJSON);
        }
        return $this->resultJSON;
    }

18 May
2 years ago

Spillmester started a new conversation JSON Casts Not Working(?)

Working on a project that goes to different sites and gets the same kind of information, but they all use different syntax for their json.

I store the json in a database. And trying to make a model that gets an attribute no mater what their syntax.

The only way I have gotten this to work is like in the sample code. But there has to be a better way.

Pretty sure I got it working before. But since I am using https I can only test on my forkrabbit server. Could there be a server setting?

The result field is of type json in database.

<?php

namespace App\MarketConnect;

use Illuminate\Database\Eloquent\Model;

class MarketAPICall extends Model
{
    protected $table = "market_api_calls";
    public $timestamps = false;

   protected $casts = [
       'result' => 'json'
   ];


    protected $fillable = [
        'method', 'pair', 'market', 'result'
    ];

  

    public function getResultAttribute($value){
        if(is_string($value)){
          //Its always a string
            return json_decode($value);

        }
        return $value;
    }
    
    public function getLastPriceAttribute()
    {
        if($this->market == 'oneofthemarketsssss'){

            return number_format($this->getResultAttribute($this->result)->Data->LastPrice, 8);
        } else {
           return $this->getResultAttribute($this->result)->markets[0]->last_price;
        }

    }



}
21 Feb
2 years ago

Spillmester left a reply on HasMany->orderBy Refresh When Relation Models Changes

This seemed to work fine. Guess I could just do the sortBy from the controller. But I like that it is one thing less to remember.

Spillmester left a reply on HasMany->orderBy Refresh When Relation Models Changes

It was there when I experimented with finding a solution. The model has a private $_participants;

Thought I could find a way to reorder the collection when $model->participants is called.

Come to think about this might work, will test and post back soon

public function participants(){

    if($this->_participants == null){
        $this->_participants = $this->hasMany(pve_encounter_participant::class)->orderBy('initiative', 'asc');
    } else {
        $this->_participants->sortBy('initiative');
    }
    return $this->_participants;
}

Edit: Will take a while as I am changing some parts needed to use the code. Will post back if works though

Spillmester started a new conversation HasMany->orderBy Refresh When Relation Models Changes

I have a model with this:

public function participants(){

    if($this->_participants == null){
        $this->_participants = $this->hasMany(pve_encounter_participant::class)->orderBy('initiative', 'asc');
    }
    return $this->_participants;
}

Then in a controller $model->participans is called, initiaive is changed on a model in the collection. Then $model->participans is called again. How do I get $model->participans to reflect the changes and be correclty ordered?

24 Jan
2 years ago

Spillmester left a reply on 5.3 Redirect Action - Not Defined

Redirect::action did not work.

return [email protected]; also does not work.

I have a feeling that CrewController should be registered as middleware or something

23 Jan
2 years ago

Spillmester started a new conversation 5.3 Redirect Action - Not Defined

Been months since I first learned Laravel. When I cam back I cant for the life of me get redirect()->action() to work. I have searched Google. But I have some missing piece that I miss.

In one controller I have:

    return redirect()->action('Pages\Member\Crew\[email protected]',
        [$npc]
    ); 

CrewController.php is in the namespace and folder App\Http\Controllers\Pages\Member\Crew;

And it has this function:

public function member(NPC $crewMember){
    //dd('dddddddddddddddddddddddddddd');
    return $this->memberTileSelected($crewMember, $crewMember->tile);
}

But I get this error:

InvalidArgumentException in UrlGenerator.php line 605: Action App\Http\Controllers\Pages\Member\Crew\[email protected] not defined.

I have tried defining various things in web.php like:

//Route::get('[email protected]', 'Pages\Member\Crew\[email protected]'); //Route::get('Pages\Member\Crew\CrewController','Pages\Member\Crew\[email protected]');

/* Route::resource('crewMember', '\App\Http\Controllers\Pages\Member\Crew\CrewController', [ 'member' => 'crewMember.member', 'only' => ['member'] ]); */

I actually do not need the browser to redirect. I want to jump the code running at another controller if that makes sense. And if there is a better way please let me know.

31 Aug
3 years ago

Spillmester left a reply on How Safe Is Laravel

Perhaps its bots (or person) with javascipt disabled doing the searches.

Spillmester left a reply on Change Variable In Collection Loop

Not sure what you want to achive, but perhaps try to use &$value

$tests = collect([1,2,3,3,4,5]); $value = '11111'; $tests->each(function($test) use (&$value){ var_dump($value); $value = '22222'; });

dd($value); //prints "22222"

edit: me to slow, glad you got it working

Spillmester left a reply on Update Users Last Activity

php artisan make:middleware UserActive php artisan make:migration AddLastActiveField composer dump-autoload -o

In folder app\http\Middleware\UserActive.php

public function handle($request, Closure $next)
{
    if (\Auth::check()) {
        // The user is logged in...
        $user = \Auth::user();
        $user->lastActive = date('Y-m-d H:i:s');
        $user->save();
    }
    return $next($request);
}

In the migration file

public function up() { // Schema::table('users', function (Blueprint $table) { $table->timestamp('lastActive'); }); }

/**
 * Reverse the migrations.
 *
 * @return void
 */
public function down()
{
    //
    Schema::table('users', function (Blueprint $table) {
       $table->dropColumn('lastActive');
    });
}

Looking back lastActive should probably be last_active as that is the common way to name mysql columns. Add the middleware to app\http\Kernel.php

protected $middlewareGroups = [ 'web' => [ \App\Http\Middleware\EncryptCookies::class, \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, \Illuminate\Session\Middleware\StartSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class, \App\Http\Middleware\VerifyCsrfToken::class, \App\Http\Middleware\UserActive::class ],

    'api' => [
        'throttle:60,1',
    ],
];

more info on middleware https://laracasts.com/series/intermediate-laravel/episodes/7

03 Aug
3 years ago

Spillmester started a new conversation BelongsTo Only Return Id As Int Not Object

namespace App\Game\Locations;

use Illuminate\Database\Eloquent\Model;

/**

  • Class City
  • @package App\Game\Locations */ class City extends Model { // protected $fillable = ['country']; protected $table = 'cities';
public function country(){
    return $this->belongsTo(Country::class, 'id', 'country');
}

}

namespace App\Game\Locations;

use Illuminate\Database\Eloquent\Model;

class Country extends Model { protected $table = 'countries'; // public function cities(){ return $this->hasMany(City::class, 'country', 'id' ); } }

namespace App\Http\Controllers;

use App\Game\Locations\City; use Illuminate\Http\Request;

use App\Http\Requests;

class GuestController extends Controller { // public function index(){ // echo 'Welcome'; $city = City::first(); $country = $city->country; dd($country); return view('theme.default.guestIndex'); } }

**dd($country); always prints 4 something that is the correct id value. How can I get it to return the class instead. The cities table is a table that I did not make through migration but copied from another database **