Terumi

Terumi

Member Since 5 Years Ago

Athens, Greece

Experience Points 16,495
Experience Level 4

3,505 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 238
Lessons
Completed
Best Reply Awards 0
Best Reply
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.

15 Mar
2 months ago

Terumi left a reply on Reset A Password With The Username Not The Email

Hello people, Using the former actions I managed to change what the user is being asked for the password reset but when the users enter their username, they get an error saying

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'email' cannot be null

which I find logical as the password_resets table uses only emails and I did not tell laravel where to find the email for the username given.

Can anyone point me to where I should read in order to make laravel resolve the email of the username given and store that into the password_resets table?

Thank you

08 Jan
1 year ago

Terumi started a new conversation Handling Passport Expired Tokens

Hello,

I'm developing a mobile app and Im protecting my api with the api:auth middleware.

Having created an access token with a request to oauth/token I pass it to every single request and everything works just fine.

When the access token gets expired though, every request to an api:auth route fails and redirects me to the login route. Is this behaviour normal? Shouldn't it return me an exception or something so that my mobile app know that the token has expired and try to issue a new one?

What is a good solution for this case?

Thank you

Terumi started a new conversation Passport Api Authentication From Non Legit Clients.

Hello everyone,

I'm developing a mobile app and I decided to have a laravel application as the backend to handle api requests and authentication via passport.

I reckon, for the authentication part I will use password grant, but, as the authentication request will reside at the client side, I will have to have a middleware attaching the client_secret at the server side.

Having said that, is there a way to really know that the authentication request has been initiated by the client I developed and not some other party client? I want to be sure that all the api requests are from my mobile app and I think that it cannot be secured with the methodology above.

Can I have your inside on this topic?

03 Jan
1 year ago

Terumi started a new conversation Incremental Apis

Hey, I think that an addition to the incremental apis series should be made. Now with laravel passport and so many mobile application frameworks, there are a lot of topics to be covered!

Cheers.

09 Apr
2 years ago
08 Apr
2 years ago

Terumi started a new conversation My Site Didn’t Send Any Data On Google Server.

Hello all, I just saw that on my website which uses socialite to login with google, when someone clicks on login with google the page returns www.ludilog.com didn’t send any data. On the request header I'm seeing

 Provisional headers are shown
 Upgrade-Insecure-Requests:1
 User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML,   like Gecko) Chrome/56.0.2924.87 Safari/537.36

I haven't changed anything two years now that the website is working. The website is www.ludilog.com

Do you know what this problem is?

14 Dec
2 years ago

Terumi left a reply on Greeklish Package

In the database seeder works now. It needed a composer dump-autoload :/

Now, in a model event it doesn't.


static::creating(function ($profile) {
                $profile->slug = Greek::convert($profile->title);
                $index = 1;
                
                while (static::where('slug', $profile->slug)->exists()) {
                    echo $profile->name." -> ".$profile->slug;
                    $profile->slug = Greek::convert($profile->title) . '-' . $index ++;
                }
                
                echo "saved";
            });

It outputs Non-static method ffy\greeklish\Greeklish::convert() should not be called statically

Maybe I'm binding something wrong?

Terumi started a new conversation Greeklish Package

Hello people,

Greeklish is a way of representing greek words with english characters. This is useful for url slugs where you want the text to describe something that is written in greek.

So I decided to make a small package for changing greek words into greeklish because this is getting used often.

I could make it a helper function, that would be very handy I know, but making it a package, I reckon will make it easily reusable, importable etc.

Anyways, having completed it, I still have some problems so I want to ask you about them.

1.I think that the package does not need a service provider because it has no dependencies. That being said, without a class binding, every time the class gets called, laravel will new up a new instance and, although it is a small class, it is not the best thing to to do.

2.Even though in my routes file I can do Greek::convert("Κάτι δικά μου δικέ μου"); Inside a database seeder class (that I'm invoking through php artisan db:seed) the exact same piece of code returns Non-static method ffy\greeklish\Greeklish::convert() should not be called statically Why does this happen?

3.Why I cannot do a composer require ffy\greeklish (this returns Could not find package ffygreeklish at any version for your minimum-stability (stable). Check the package spelling or your minimum-stability)

and instead I have to add it manually to my composer.json file.

Thank you people!

06 Dec
2 years ago

Terumi started a new conversation Expose To Window

Hello, I found a javascript library that creates hexagons. That library has exports statements for use with webpack.

http://www.redblobgames.com/grids/hexagons/codegen/output/lib.js

in my bottstrap.js file I write

window.Hexagon = require('./hex');

And on the chrome console I have a window.Hexagon object available.

The problem though, is that the library references functions on the window scope and not on the window.Hexagon and it fails.

How can I append to window the exports of the library? I'm a complete noob on the subject so my wording can be flawed, sorry about that.

25 Oct
2 years ago

Terumi started a new conversation Organizing Too Many Checks

Hello all, I need some help because everything is so confusing... I'm creating a little game in which you have a ship and go from one port to another and you are buying and selling resources. So my models are: -a player who has a... -a ship which has many... -cargo_spaces each of them holds a... -resource which has a price on the... -port in which is being sold/bought (if that resource is demanded/ offered)

So anytime a user wants to sell something I have to check these things: -Does the user ship contains a cargo_space which holds a resource of a given type? -Does the port (in which the users ship is in) demands that kind of resource? -In which price?

Anytime a user wants to buy something I have to check: -Does the user ship is in a port which has available a resource of a given kind? -In which price does the port sell that resource? -Can user afford buying that resource? -Does the ship in that port has a free cargo_space to hold that resource?

I could put that checks on the controller, or in one of the models, but it seems totally wrong to do that. What do you recommend me to do? I think have to create different classes for each action/ check but I don't know how exactly to do that. Where should I store them (anywhere I reckon but an example would be good)? Should every class aggregate all the models needed and run methods on them?

Any guidance would be appreciated.

Thank you

05 Oct
2 years ago

Terumi left a reply on Can Queue Workers Run On A Windows System?

Oh, I forgot to mention that I'm using redis...

Terumi started a new conversation Can Queue Workers Run On A Windows System?

I'm trying to run a queue:work command but nothing works. When I hit

public function testjob() {
            $job = ( new testjob() )->delay(Carbon::now()->addSeconds(4));
             $this->dispatch($job);
        } 

on my controller, the job gets dispatched and the public function handle() { dd('sddd'); }

methods gets instantly called.

Any ideas?

20 Sep
2 years ago

Terumi left a reply on Delaying Actions

Thank you guys, I'mm check these options out!

19 Sep
2 years ago

Terumi started a new conversation Delaying Actions

Hello, I'm creating an app in which a user can create a message to be delivered to other users with delay. Is it possible with laravel only?

Right now I'm creating the message with a time-to-deliver column and I have a cron job running in the background to check if there are any messages to be delivered. If so, I broadcast an event and the receiver receives it.

The problem is that I don't like the cron solution because it has to run every 15sec or so, and if the messages are many, maybe there will be a small massacre happening there.

Are there any other solutions you can think of? Thank you.

20 May
3 years ago

Terumi left a reply on Reverse Pagination Order

I managed to solve it this way: if(!Input::has('page')) { if (Auth::check()) { if (!Auth::user()->reverse_messages) { return Redirect::to($messages->url($messages->lastPage()), 307); } } else { return Redirect::to($messages->url($messages->lastPage()), 307); } }

Terumi started a new conversation Reverse Pagination Order

Hello,

I've created a service in which people are discussing in a facebook-like wall. The messages are displayed with pagination. I'm offering a way for people to see their messages in chronological order and in a reverse order. For the reverse order, the last message sits on top. For the chronological the oldest sits on top and if someone wants to see the last message, he has to press the last pagination button.

What I would like to happen is that whenever someone goes to a discussion page, that page by default to load the last page of the pagination so the users can see the last message on the bottom of the page.

Is this possible?

25 Apr
3 years ago

Terumi left a reply on Overriding Package Routes (or Adding A Middleware)

Let me rephrase the question... I installed a package which add to an application some routes. Route::group(['prefix'=> 'package', function(){ Route::get('something', 'PackageController@something'); Route::get('something-else', 'PackageController@somethingElse'); // etc //etc }]);

What I need is to add a middleware to these routes WITHOUT having to change the /vendor/provider/package/Http/routes.php file. Is this possible?

23 Apr
3 years ago

Terumi started a new conversation Overriding Package Routes (or Adding A Middleware)

Hello all, I have a package with some views. I want the users to be able to see these view only of they are "activated" (that is if they have confirmed their email). I could easily change the package routes file to include a middleware but on the next update, I would have to do it again.

Is there a way to limit access to that package routes without changing the package code?

07 Apr
3 years ago

Terumi left a reply on TokenMismatchException In VerifyCsrfToken.php Line 67 In Laravel 5.2

What did the trick for me was to set the session host to localhost in the config/session.php file.

30 Mar
3 years ago

Terumi left a reply on TokenMismatchException In VerifyCsrfToken.php Line 67 In Laravel 5.2

Same problem here... Any solution? All the things that had to be checked, were checked (route middleware, new kernel, csrf_token on view) but the problem persists.

11 Feb
3 years ago

Terumi left a reply on Running Artisan Commands Sequentially

@willvincent : will one command be executed only after the previous has been completed?

Terumi left a reply on Running Artisan Commands Sequentially

yes, but how can I return thatr a command has ended? An after that what do I do? A while loop to see if the first one has ended?

Terumi started a new conversation Running Artisan Commands Sequentially

Hello, I have some artisan commands which delete some data from a database and perform a curl request to fetch and populate the database with data. What I need is to make them run in order, when one has finished, I need another to start. Now, I have a schedule running in Kerner.php but I reckon that things get messed up and my webserver doesn't populate until I restart it.

Right now I have the commands runing at xx:xx the other one at xx:xx+2 etc.

I think that I have to make a command that runs on xx:xx and calls all the commands one after the other, but I don't know how to do it.

Can anyone help? Thank you

19 Oct
3 years ago

Terumi left a reply on Package: "cannot Find Service Provider" And Autoloading

I just had to include the autoload section in the package composer.json

Thanx :)

Terumi started a new conversation Package: "cannot Find Service Provider" And Autoloading

Hello,

I've made a small package which I uploaded it to the packagist. When I load that package in a new laravel installation, after passing the service provider, laravel squaks that cannot find it.

When, on the main composer.json Ι pass on the autoload section, on psr-4 the package everything works.

Now my question is: do every package need a psr4 entry, or am I doing something wrong?

the package is ffy/notifications:"dev-master"

thank you

07 Oct
3 years ago

Terumi left a reply on How To Give A Model Some Extra Functionality.

The notifications service will give the user the ability to receive notifications like here on laravel (the red bubble next to your name).

06 Oct
3 years ago

Terumi left a reply on How To Give A Model Some Extra Functionality.

Sorry about my obscurity.

I want to have a method on user model that creates a notification associated with it.

    $user = App\User::find(1);
    $user->notify('Hello Mate!');

The notify() method, to my knowledge should call a class (say NotificationSystemName) that creates a notification for the user.

public function notify($message)
    {
            NotificationSystem::notify($message);
    //the notify method will create a new notification in the db
    //it should attach it to the user as well... 
    }

The questions are:

Where should this class (NotificationSystem) should reside? How can I pass from the User model method the id of the user?

Hope that all these make sense.

Terumi left a reply on How To Give A Model Some Extra Functionality.

I want to have in my User model:

        public function notify($message)
        {
                NotificationSystemName::info($message);
        }

But where do I have to register NotificationSystemName class?

Terumi started a new conversation How To Give A Model Some Extra Functionality.

Hello, I'm creating a notifications system for the users of a site. I have a notification model and a user model. What I want is to create a clean way to notify a user, something like this... $user->notify('welcome aboard', 'some data', 'some other data');

How is this possible?

30 Sep
3 years ago

Terumi left a reply on Laravel Applications And Encryption (zendguard, Ioncube).

Because laravel uses many magic methods that, to my knowledge, depend on strings. If you obfuscate your code, the strings aren't going to be messed up?

Terumi started a new conversation Laravel Applications And Encryption (zendguard, Ioncube).

Hello, Just wandering, is it possible to encrypt the source code of a laravel application using zendguard or ioncube in order to protect your code from copy?

17 Sep
3 years ago
15 Sep
3 years ago

Terumi left a reply on Polymorphic Relations And Scope.

I don't understand what you mean to use a Boolean, and why obviously latest() does not work with wherehas. Can you please explain?

Thank you.

Terumi left a reply on Polymorphic Relations And Scope.

What I'm doing is $openTickets = Ticket::ofStatus(0)->get();

or

        $openTickets = Ticket::ofStatus(1)->get();

But if a ticket had at some point the given id, it will be included in the collection the above code fetches. It completely disregards the current_status, the latest status of the ticket.

Terumi left a reply on Polymorphic Relations And Scope.

A problem occured with the above code; If I do something like
$openTickets = Ticket::ofStatus('open')->get();

It fetches not only the tickets with current status of 'open', but all the tickets that once had that status. Again the code is:

        public function statuses() {
            return $this->hasMany('App\TicketStatus');
        }

        public function current_status() {
            return $this->hasOne('App\TicketStatus')->latest();
        }

        public function scopeOfStatus($q, $status) {
            $q->whereHas('current_status', function ($query) use ($status) {
                $query->where('status_id', '=', $status);
            });
        }
11 Sep
3 years ago

Terumi left a reply on Polymorphic Relations And Scope.

found it myself!

        public function scopeOrphans($q) {
            $q->has('current_owner', '=', 0);
        }

Terumi left a reply on Polymorphic Relations And Scope.

And what if you want to gather the Tickets that have got no TicketStatus assigned? Or the tickets that have no TicketStatus OR have a status that is not $x?

Thank you again

10 Sep
3 years ago

Terumi left a reply on Polymorphic Relations And Scope.

Worked like a charm! Thank you!

Terumi left a reply on Polymorphic Relations And Scope.

To rephrase, A Ticket may have multiple TickeStatus objects. A ticket can be opened, closed, handled, postponed and so on and so forth. So, any given time a Ticket status is the status of the last TicketStatus associated with it. Is there any way to query from the database the Ticket object that have a certain status? Something like this: $openTickets = Ticket::ofStatus('open')->get(); $closedTicket = Ticket::ofStatus('closed')->get();

Thank you

09 Sep
3 years ago

Terumi left a reply on Polymorphic Relations And Scope.

I'm not on my pc right now but I reckon that the function above returns the latest status of the ticket with id $id.

What I need is to have all the tickets with their latest status equal to $x.

Terumi left a reply on Polymorphic Relations And Scope.

Hello again, I made the thing a lot simpler. Now I have some Tickets that have many TicketStatus

ticket model: class Ticket extends Model { protected $table = 'ticket';

            public function statuses() {
                return $this->hasMany('App\TicketStatus');
            }

            public function getLastStatusAttribute() {
                $status = $this->statuses()->orderBy('created_at', 'desc')->first();

                return $status;
            }
    }

Now, how Can I create a query scope on Ticket model in order to get the status from the last created TicketStatus associated with the Ticket Model?

I want to have something like $openTickets = Ticket::ofScope(0)->get();

Thank you.

06 Sep
3 years ago
05 Sep
3 years ago

Terumi started a new conversation Polymorphic Relations And Scope.

Hello all, I'm creating a ticketing system with laravel and I have some problems:

I have a ticket model which has some events (ticket_event model) the ticket event model has: ticket_id creator_id eventable_id eventable_type

it belongs to ticket

public function ticket(){ return $this->belongsTo('App\Ticket'); }

and has some eventables:

public function eventable(){ return $this->morphTo(); }

Now, the eventables, or the Events might be TicketStatus, TicketDelegation etc etc

for example TicketStatus model has a field: status_id (an enum of some sort)

and it is an eventable:

public function eventable(){ return $this->morphToMany('App\TicketStatus', 'eventable'); }

Now, I want to extract from the database the Tickets that have a certain status, say 0. To do that I have on the Ticket model an accessor function, this one:

public function getStatusAttribute(){ $last_ticketStatus_event = $this->events()->where('eventable_type', 'App\TicketStatus')->orderBy('created_at', 'desc')->first();

$last_ticketStatus = TicketStatus::find($last_ticketStatus_event->eventable_id);

return $last_ticketStatus->status_id;

}

and a query scope:

public function scopeOfStatus($q, $type){ return $this->getStatusAttribute() == $type; }

If I do something like

$t = Ticket::find(20); dd($t->status);

everything works fine.

But if I do something like

$tickets = Ticket::ofStatus(0); dd($tickets);

I get an error exception "Trying to get property of non object" on this line, in Ticket model:

$last_ticketStatus = TicketStatus::find($last_ticketStatus_event->eventable_id);

Does anyone knows what it is?

Thank you

01 Sep
3 years ago

Terumi started a new conversation Model Encaptulation

Hello,

I have a Post model which can have some "Events". The events are "status change", "new message", "owneship change", etc.

Now, in order to track all these "events" in a chronological order I created an "event_post" table in which I store this info:

id post_id event_type event_type_id timestamps

That way, when a new message or status change occurs, I can store in the "event_post" table that a given post has a new thing going on.

The problem is that I don't know how to implement the relationship:

A post has many events, but I don't have a Event Model, because an event might be either a new message, status_change, ownership_change etc.

Does anyone know how to solve this?

13 Aug
3 years ago

Terumi left a reply on Advanced WhereIn

Ι don't get how it can be done...

12 Aug
3 years ago

Terumi started a new conversation Advanced WhereIn

Hello, I have a webpage with posts. Each post belongs to many tags. I have a searchbox in which you can search for the posts that have some tags. Say that: Post-1 has "tag_1", "tag_2", "tag_3", "tag_4" and Post-2 has "tag_2", "tag_3", "tag_4" and Post-2 has "tag_3", "tag_4", "tag_5"

when the user inputs "tag_4" the search should yield Post_1, Post_2, Post_3

when the user inputs "tag_4", "tag_5" the search should yield Post_3 (because only Post_3 has ALL these tags)

how can this be done using elloquent?

Right now my code is $tags = [4,5]; $posts = Post::whereHas('tags', function ($q) use ($tags) { $q->whereIn('tag.id', $tags); })->get()

and it returns the posts that have a tag with either id. But I want the posts with tags of all the ids provided.

Thank you

10 Aug
3 years ago

Terumi started a new conversation Request Based Validation And Old Input.

Hello, How is it possible to preserve the input data a user wrote on a form after a request based validation failed and redirected him back?

Thank you

28 Jun
3 years ago

Terumi left a reply on Upcoming Vue.js Screencasts

It would be nice if you showed us how to handle file uploads using vue.js as this subject isn't covered anywhere on the internets.

:)