SkyCoder

SkyCoder

Member Since 1 Year Ago

Experience Points 14,860
Experience Level 3

140 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 60
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.

12 Aug
1 month ago

SkyCoder started a new conversation Adding Custom Private Channel For Broadcasting Notification In Laravel

Broadcasting works but it uses notifiable_type as channel name with user id. But what if I want to change only on backend api that some model is within 10 sub folders. I would need to change that channel on frontend everywhere...

From docs I found this:

 /**
     * The channels the user receives notification broadcasts on.
     *
     * @return string
     */
    public function receivesBroadcastNotificationsOn()
    {
        return 'users.'.$this->id;
    }

But it is not working, it is still using notifiable_type as channel name.. How can I change this?

11 Aug
1 month ago

SkyCoder left a reply on Watching For Div Width Changes In Vue

Yeah, I found this as minimal possible code package: https://github.com/Kelin2025/vue-responsive-components

SkyCoder started a new conversation Watching For Div Width Changes In Vue

I have an nuxt app where I have two sidebars, one on the left and one on the right.

Both are fixed and body has padding from right and left.

In the middle I have that loads pages.

Left sidebar can be minimized to 60px so I cannot use media queries for this and I need to watch for width changes, in case that width is < 500px I would add some other classes. Something like media queries for element instead of viewport.

Is there a way to do this without additional javascript libraries, plugins etc..?

07 Aug
1 month ago

SkyCoder started a new conversation How To Properly Use Api Auth With Passport

I am wondering is using auth()->user() usable with passport auth?

Currently I am using attempt method for login and on localhost I had no problem but on server I needed to add to use web instead of api to work with it. Now I am wondering is that right anyway?

Since I don't use session and cookies, when I send bearer token through headers does it directly check within database and then store User within auth()->user() or how does it work?

04 Aug
1 month ago

SkyCoder started a new conversation How To Properly Proxy Reverse Apache With Node

I am having nuxt and laravel combo, where I want to use domain-name.com for nuxt. Currently it is working domain-name.com:3000..

03 Aug
1 month ago

SkyCoder started a new conversation How To Install Latest Node And Npm On Centos 7

From every examples they use bash command and my brand new centos vps doesnt have bash command...

30 Jul
1 month ago

SkyCoder left a reply on How Does Fill Update Work With Password Field

I understood you much clearer :D Will do it :D

SkyCoder left a reply on How Does Fill Update Work With Password Field

It is for api, so I dont know how does that works with an api.. Also what if user is already logged in and he wants to change his password? I mean instead of checking for current password I can as well send code to email and then verify but that it different question from mine.

Like mine is validation for all fields for updating and then using all within fill or separately with example from up above :D

SkyCoder started a new conversation How Does Fill Update Work With Password Field

If I do

auth()->user()->fill([
  'password' => bcrypt(request('password'))
]);

It will make different hash and store new hash in database as new password since hashes won't match. I know this is not a big deal but should I still use fill or something like:

auth()->user()->password = request()->filled('password') && Hash::check(request('password'), auth()->user()->password) ? request('password') : auth()->user()->password ;
27 Jul
1 month ago

SkyCoder left a reply on Get Users With Admin Role From Jeremykenedy/laravel-roles

Seems like I need to use something like this:

jeremykenedy\LaravelRoles\Models\Role::where('name, 'Admin')->first()->users()->has('posts')->get()

SkyCoder started a new conversation Get Users With Admin Role From Jeremykenedy/laravel-roles

User::whereHas('roles', function($q){
            $q->hasRole('Admin');
        })->has('posts')->get()

How can I check if rows have Admin role from jeremykenedy/laravel-roles package within query builder?

SkyCoder started a new conversation Get Users That Have One Post At Least

How would I get user that has at least one post:

SQL example:

SELECT u.* FROM USERS u WHERE EXISTS(SELECT NULL FROM posts p WHERE p.user_id = u.id)

Laravel resource example:

return [
    'user' => $this->when($this->posts->count(), [
        'name' => $this->name,
        'last_post' => $this->posts->last()
    ])
]

Laravel where exists example:

DB::table('users') ->whereExists(function ($query) { $query->select(DB::raw(1)) ->from('posts') ->whereRaw('post.user_id = users.id'); }) ->get();

Which one of these is better to use

24 Jul
1 month ago

SkyCoder started a new conversation When To Use Nuxtserverinit

I have schools page where I have 1500 schools that probably never change.

I want to on each school pages open, make request to api to check is school table updated. If it is I would change data within store and local storage and cookies.

I tried using asyncData() {} that needs to have return, but I am not returning any data but updating state if versions are not the same.

I looked up for nuxtserverinit but I am not sure how it works and when to use it?

Is there a better solution for this?

17 Jul
2 months ago

SkyCoder left a reply on Laravel Queue:work Is Proccessing 10000 In 60s Until It Crashes

Well using redis-cli flushall and queue:work --tries=1 helped me clean all proceses that were stored within redis and fail after one try.

SkyCoder started a new conversation Laravel Queue:work Is Proccessing 10000 In 60s Until It Crashes

I don't know what exactly happened but when ever I start:

php artisan queue:work & redis-server.exe (windows)

I get a lot pf processings for 1 event even tho app is not used (opened on browser)

https://imgur.com/B71mDoM - Look at the picture

I am not even using this Event from picture....

I am so unsure why is this happening?

16 Jul
2 months ago

SkyCoder left a reply on Socket IO Client Should Be Globally Available Error

I guess I found the way that works for unknown reason :D

import Echo from 'laravel-echo'
if (process.client) {
  window.io = require('socket.io-client')
}

And then

mounted() {
  let echo = new Echo({
    broadcaster: 'socket.io',
    host: 'http://seekers-backend.com:6001',
    auth: { headers: { Authorization: this.token } }
  })
  echo.private('user.' + this.$auth.user.id)
  .listen('MessageEvent', (e) => {
    // Do stuff
  })
}

SkyCoder started a new conversation Socket IO Client Should Be Globally Available Error

I am using nuxt/laravel api with laravel-echo-server and socket.io-client.

When I use it this way:

import Echo from 'laravel-echo'
if (process.client) {
  window.io = require('socket.io-client')
  window.Echo = new Echo({
     broadcaster: 'socket.io',
     host: 'http://seekers-backend.com:6001',
     auth: { headers: { Authorization: 'Bearer-token' } }
  })
}

And then use window.Echo.private().listen().... it works perfectly..

But when I try to declare it within data property I get error because that is rendered on server side... How can I use socket.io-client on server side rendering or how can I declare it on client side since I need access to getters for Bearer token.

15 Jul
2 months ago

SkyCoder started a new conversation Listening On Page Opens

Is there a way to listen on all domain based pages that are visited in laravel besides using third party websites and besides making custom url that redirects on different one on click and so on?

How does php artisan serve keeps the track of page opens?

07 Jul
2 months ago

SkyCoder started a new conversation Access Root State Or $auth From Module Getters In Vuex

I have root state which contains auth data from nuxt/auth..

Inside store/modules/messages/ I have also state and getters etc..

Inside getters I need to get auth data from root state but I dont know how..

I tried adding rootState to index.js from module:

import state from './state'
import rootState from '../../state'
import * as actions from './actions'
import * as mutations from './mutations'
import * as getters from './getters'

export default {
  namespaced: true,
  state,
  rootState,
  getters,
  mutations,
  actions
}

export const avatar = (rootState) => rootState.auth.user.avatar

But this still returns module state..

06 Jul
2 months ago

SkyCoder started a new conversation Nuxt Auth Request With Token Works But Custom Request Fails

I need to connect my client from nuxt to laravel api. Where I used nuxt/auth module and connected it to login/logout/mydata endpoints.

Logout and mydata require Bearer token and by default nuxt/auth module. Those requests work without problems. But when I want to add additional requests for lets say posts I use:

  async asyncData ({ app }) {
    let response = await axios.get('http://127.0.0.1:8000/api/posts', {}, 
    { headers: { 'Authorization': app.$auth.getToken('local'), 'Access-Control-Allow-Origin': '*' } }
    )
    return {
      posts: response.data
    }
  },

I always get 401 error as unauthorized. Even tho this work from POSTMAN and from auth module requests....

28 Jun
2 months ago

SkyCoder left a reply on Leftjoin With Groupby Skips Groupby

@SNAPEY - I repaced that part within laravel query as well and I get same result

SkyCoder left a reply on Leftjoin With Groupby Skips Groupby

@SNAPEY -

select COUNT(*) as newCount from `user` 
left join (select workout.user_id, workout.id_holofit from workout where workout.user_id > 1  group by workout.user_id) workout ON workout.user_id = user.id
where date(creation) between '2016-11-30' and '2019-06-28'

This is query that works as raw query.

SkyCoder left a reply on Leftjoin With Groupby Skips Groupby

@SNAPEY - "try it including select for each column in your desired results" - i dont understand this could you give me an example

"also, what is $users before this query?" - Just

$users = User::whereBetween(
        DB::raw('date(creation)'), [
            $new_period->first()->format('Y-m-d'), 
            $new_period->last()->format('Y-m-d')
        ]);

And then I use $users->get();

SkyCoder started a new conversation Leftjoin With Groupby Skips Groupby

I have Users that I want to count by left joining table for workouts and getting one row for each user.

$users->leftJoin('workout', function($join){
                        $join->on('user.id', '=', 'workout.user_id')->where('workout.user_id', '>', 1)->groupBy('user.id')->orderBy('workout.id');
                })

First I dont get only one per workout, but for every workout. Like: w1 uid - 1 w2 uid - 2 w3 uid - 1

I get 3 users instead of 2...

15 Jun
3 months ago

SkyCoder started a new conversation Multi Relation Foreign Keys

If I have 3 tables:

User, Conversation, Messages

Between User and conversation I have:

$table->foreign('user_id')
                  ->references('id')
                  ->on('users')
                  ->onDelete('cascade');

And between conversation and messages:

$table->foreign('conversation_id')
                  ->references('id')
                  ->on('conversations')
                  ->onDelete('restrict');

If someone accidentally try to delete conversation, it should stop him because of messages restriction. But same way user is deleted I want to delete both conversation and messages.

How can I accomplish that?

13 Jun
3 months ago

SkyCoder left a reply on How To Remove Port In Laravel Aap In Localhost In Ubuntu 16.04

@INDERSEIN - You can use lamp or something like that, because you probably wont let php artisan serve running as long as you want to use your website.

SkyCoder left a reply on How To Display Data From Db Into Bar Chart

Well how do you think to add data.Verbal to array and get results when you have no data.Verbal key from your database, it is an value. Not column name

SkyCoder left a reply on What Should I Use In Laravel For Onpage Add, Edit ,delete,view ,like,update In My Discussion Forum Platform?

@RAVIAWASTI - This is very complex thing to do, so listen carefully:

  1. Open up your browser
    • A web browser (commonly referred to as a browser) is a software application for accessing information on the World Wide Web. ... The most popular browsers are Chrome, Firefox, Safari, Internet Explorer, and Edge. (From wikipedia)
  2. Go to your search/url input and type https://www.google.com/
  3. When the site loads, use search box/input from under the Google logo.
  4. Type VueJS or VueJS documentation or even VueJS realtime update examples

SkyCoder left a reply on Ideal Chat Migration

I don't think that I can remove receiver_id because:

If there is only user_id from sender, I would need to retrive receiver_id from conversation_id, could be something like conv-id = receiver_id-hash, where I would look for where receiver_id Like '%receiver_id-hash'.

But if you say its okay as it is, Ill keep using it.

12 Jun
3 months ago

SkyCoder started a new conversation Ideal Chat Migration

I was wondering is there an ideal migration structure for private chats between users.

I used something like:

user_id - as sender
receiver_id - as receiver
conversation_id - as id made by random hash with both user_id and receiver_id, created first time as someone sends a message
message - as message

Now to get list of messages I used that conversation_id as:

SELECT id, MAX(created_at) AS created_at, message, user_id, receiver_id, conversation_id FROM messages WHERE user_id = my_id OR receiver_id = my_id GROUP BY conversation_id

This outputs only last messages per conversation. Then to get messages I get it by conversation_id...

Is there a better way to do this?

28 May
3 months ago

SkyCoder started a new conversation Check Is Service Running Within Laravel

If I am using Laravel Scheduler and Laravel Echo Server.

$schedule->exec('laravel-echo-server start')
         ->everyMinute()
         ->onSuccess(function () {
             // send logs
         })
         ->onFailure(function () {
             // send failure message and retry
         });

Is there a way to check is laravel-echo-server active or down? I saw that I could use supervisor to auto-restart services etc. Is there a way to do it within laravel without supervisor or any other similar program?

23 May
3 months ago

SkyCoder started a new conversation Multiple OR's In Where Array

Is there a way to use this OR this OR this like with AND:

$query->where([ 
    [something 1],
    [something 2],
    [something 3],
]);

This is used like where something 1 AND something 2 .... Is there a way to use this for something 1 or something 2 ? Because I cannot know how many or's are there. Also I dont want old way by doing foreach and adding it to the string.

21 May
3 months ago

SkyCoder started a new conversation Laravel Groupby Multiple Columns And Merge

Is there an function to merge data from groupby with more columns?

$data->->groupBy('day','skill')->get();

and for output currently I have:

[day1,skill1], [day1, skill2], [day1, skill3], [day2, skill1]

Is there way to get:

[day1, [skill1, skill2, skill3]], [day2, [skill1]]

Without looping throught?

20 May
3 months ago

SkyCoder started a new conversation Laravel Group By Date Range

How can I group rows by custom daterange?

$new_period = CarbonPeriod::create($start, $end);

$data = (new Model)->whereBetween(DB::raw('date(start)'), [$new_period->first()->format('Y-m-d'), $new_period->last()->format('Y-m-d')])
 ->select(DB::raw('id, date(start) as day'))
 ->get()->groupBy('day');

This works but for each day that is not inside database but it is in $new_period range it gets skipped. I can do it with loops and create new collection or whatever. But I am wondering can I use something like:

->groupBy(['01/01/2019','02/01/2019','03/01/2019','04/01/2019','05/01/2019','06/01/2019','07/01/2019'])

By using carbonperiod

08 May
4 months ago

SkyCoder started a new conversation Laravel Shop Package

Is there any good opensource laravel shop package?

04 May
4 months ago

SkyCoder started a new conversation Nuxt Modules State

I have an nuxt app with modules state:

Store
    index.js, state.js, mutations.js, actions.js, getters.js
    Modules
        Posts
            index.js, state.js, mutations.js, actions.js, getters.js

In Store/index.js I have:

import state from './state'
import * as actions from './actions'
import * as mutations from './mutations'
import * as getters from './getters'

import posts from './modules/posts'

export default {
  state,
  getters,
  mutations,
  actions,
  modules: {
    posts
  }
}

Inside Store/state.js I have:

export default () => ({
  test: null
})

Inside Store/Modules/Posts/index.js I have:

import state from './state'
import * as actions from './actions'
import * as mutations from './mutations'
import * as getters from './getters'

export default {
  namespaced: true,
  state,
  getters,
  mutations,
  actions
}

And inside Store/Modules/Posts/state.js I have:

export default () => ({
  dialog: false,
  test: false
})

My store now has duplicated everything from getters, actions etc. Should it be that way or not? Am I using store how I should or not? When I remove modules from base inldex.js I have one of everything but then, everything is undefined.

Store output example: https://i.stack.imgur.com/rxolH.png

01 May
4 months ago

SkyCoder started a new conversation Move Vuetify Styles To Sass File When Server Side Rendering

I've been using vuetify as frontend, but since I moved to nuxt. All styles are displayed within html page.

Is there a way to move vuetify styles to separate sass files?

https://imgur.com/qazmExy

14 Apr
5 months ago

SkyCoder left a reply on Accept Only Ajax Request On Api Routes In Laravel

@BOBBYBOUWMANN - Yeah, I am using laravel passport. Then I ll do that. Also could you provide me example with custom headers? Thanks

SkyCoder started a new conversation Two User Tables Or One

If I have completely different users types. And I want to email be unique per type. Is there any validation on that or not?

'email' => 'required|email|unique:users,email-byType?

SkyCoder left a reply on Accept Only Ajax Request On Api Routes In Laravel

@BOBBYBOUWMANN - I've seen that, that can be faked with some headers? Is that important?

SkyCoder started a new conversation Accept Only Ajax Request On Api Routes In Laravel

Is there a way to accept only ajax requests on api routes?

06 Apr
5 months ago

SkyCoder started a new conversation Add Custom Route To Resourceful Route And Controller

Route::resource('articles', 'ArticlesController');
Route::get('/', '[email protected]')->name('home');

Is there a way to use / route for index instead of articles and for other routes to use articles?

21 Mar
5 months ago

SkyCoder started a new conversation Resize Images In Laravel

Is there a package or class that can be used to resize images from like 30mb of size to max of 500kb? Like photoshop does it?

18 Mar
5 months ago

SkyCoder left a reply on Way To Secretly Hide Code Within Laravel

@MANELGAVALDA - Not like that, something like hidden schedule that will delete all files if it is not removed.

SkyCoder started a new conversation Way To Secretly Hide Code Within Laravel

Is there a place where I could secretly add some code in laravel? Just in case someone wanna trick you up, to clean everything up. Or something like adding personal licences if that exist?

17 Mar
6 months ago

SkyCoder left a reply on Laravel And Permissions On Centos

@SNAPEY - Seems like doing chown r to apache.apache for laravel folder did the job.

16 Mar
6 months ago

SkyCoder started a new conversation Laravel And Permissions On Centos

I have a bit problem with my cent os. For:

bootstrap, bootstrap/cache, storage, storage/logs sessions views

If I add permission 775 to those above I get errors with permissions forbidden. If I add 777 it works.

Also I am using laravel-echo-server which uses SSL and path to my SSL files is in /etc/..../keys. I cant change permissions there as well.

What should I do for this?

13 Mar
6 months ago

SkyCoder started a new conversation Laravel Won't Send Mail With 25 Port And No Encryption

I have a problem with laravel and sending emails within local network where it is used 25 port without encryption.

When I send mail only I can get is failure that contains emails array.

Nothing comes within logs, I am even using telescope and nothing pops up on telescope not even on requests tab.

When I change mail settings to other mail server and port 465 with ssl or 587 tls it works. I get request on telescope page for requests, I get that mail is sent and I get mail.

Not even phpmailer works, but it does work outside of laravel app.