mushood

mushood

Member Since 2 Years Ago

Port Louis

Back End Web Developer at Esokia Web Agency ltd

Experience Points 158,250
Experience Level 32

1,750 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 1093
Lessons
Completed
Best Reply Awards 76
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.

09 Jun
1 month ago

mushood left a reply on Handling Guzzle GET Response Data

I'm not sure that you are supposed to have the "\n" in your response.

I used this json validator (https://jsonlint.com/) and found that a valid JSON would be

{
    "make": "Ford",
    "model": "Focus",
    "VRM": "AB12CDE",
    "VIN": "XXXXXXXXXXXXXXXX"
}

So this should work:

$str=str_replace("\r\n","",$response);
$array_response = json_decode($str, true);
$make = $array_response['make'];

Now you have an array and you can easily access the make like explained

mushood left a reply on Send Users Array To Notification

\Notification::send( $users , new EMAIL($info));

mushood left a reply on New Metric For Leaderboard

I think an indication of answer quality is already here but not used; the upvote feature. Maybe its due to the fact that you have to hover over the answer to show the number of hearts it has instead of showing it upfront. It would encourage users to "like" answer more. Maybe.

Also this metric as you are proposing (Best reply award count / reply count) * 100. would mean that if you get a best reply on first answer, you would have a 100% score. You'd be more hesitant to answer in order not to ruin your score.

mushood left a reply on Include Auth Or Personal Variable In Config.

I have not used this package before, but why exactly are you doing this.

From the ReadMe, you have to publish the config file like so

php artisan vendor:publish --tag=ckfinder

Then for auth, you should use a middleware, also explained in the ReadMe. You could specify the middleware you are using for auth in your config:file. https://github.com/ckfinder/ckfinder-laravel-package/blob/master/src/config.php

The key is $config['authentication'];

mushood left a reply on How To Order A Product Only Once In Laravel?

When reading the code, its like you are say, the user can only bid ONE time in a category. Is that logic correct?

$order = Order::where('user_id',auth()->id())
            ->where( 'category_id', request('category_id'))
        ->exists();

//check if an order is actually returned here when you have already bid. Look at the attributes and check if this looks correct to you
dd($order);

if ($order) {
 alert()->error('Warning', 'You ordered already');
        return redirect()->back();
}

mushood left a reply on Best Way Of Keeping Cart Active After Logout

The cart should be related to the user. When the user logs in again, fetch his cart and set the cart ID to the session again.

Also the user can have a remember_me token in the login page, if he checks this box, when he comes back to the site, he will automatically login again. Then you can fetch his cart when he comes back.

Alternatively, you could set a cookie with the cart id which will stay longer even if the user closes the browser. However, what happens if he clears his cookie?

mushood left a reply on How To Pass Object To Validation Rules() Method

You should not allow the user to send validation data. Because you would need to validate the validation. The validations rules should be server side ONLY.

However, you can have a parameter in your request called, rule_type. Then set this value to 1, 2, 3 for example. Then based on this value, you apply different rules

const RULE_1 = 1;
const RULE_2 = 2;

store(Request $request)
{
if ($request->rule_type == self::RULE_1) {
$request_validate(first_type_of_rule);
}

if ($request->rule_type == self::RULE_2) {
$request_validate(second_type_of_rule);
}
}

Be careful not to abuse of this and have 10 different rules, maybe you need to have different objects then. A parent class with childrens and each have their own rules would be cleaner.

mushood left a reply on Call To A Member Function Connection() On Null.

If your on linux, try running ls -la in the root directory and the bootstrap directory and copy paste the output here.

Secondly, instead of deleting the config file, use the command instead.

mushood left a reply on Call To A Member Function Connection() On Null.

You need to change your file permissions to allow the application to generate this file automatically. Check user group as well.

07 Jun
1 month ago

mushood left a reply on Create An Up To Date Feed

@msiri You're welcome :D

mushood left a reply on Create An Up To Date Feed

@robstar Yes, but it can cause unexpected results when I was looking into it. I preferred not to chain just to be on the safe side

mushood left a reply on Create An Up To Date Feed

Hey I found the solution here: https://medium.com/@tadaspaplauskas/quick-tip-laravel-eloquent-collections-merge-gotcha-moment-e2a56fc95889

Its because reply and news have the same id. So this should work

$merged = new \Illuminate\Database\Eloquent\Collection; 
foreach ($newsReply as $reply)
    $merged->push($reply);
foreach ($newsOpportunity as $opportunity)
    $merged->push($opportunity);
foreach ($newsComment as $comment)
    $merged->push($comment);

mushood left a reply on Using Controller To Open New Window For Redirect

for the text

bla bla bla <span @click="fetchUrl"> Your word </span> bla blla

//the fetchUrl is a function that fetches the url. It hits your show function in your controller. Return a json response containing the url instead of a redirect. 
//On success, use window.open(url)

mushood left a reply on Create An Up To Date Feed

try this:

$merged = new \Illuminate\Database\Eloquent\Collection; 
$merged = $merged->merge($newsReply);
$merged = $merged->merge($newsOpportunity);
$merged = $merged->merge($newsComment);
06 Jun
1 month ago

mushood left a reply on PhpStorm Methods Not Found In PhpUnit Tests

You might need to set your languages and framework to help phpstorm with discovery

mushood left a reply on One Larave Application , Many Databases

One complete answer: https://fideloper.com/laravel-multiple-database-connections

Multi-tenancy concepts can help as well: https://medium.com/@edu_96787/building-a-multi-tenancy-laravel-app-with-multi-database-using-hyn-multi-tenant-4f1cdbf99de

How I would do it? Depending on how many companies you actually have, I would have one application for each company, connected to one database. When there are code changes, I would look into application such as Jenkins to deploy the changes to each project, so I dont have to do them all manually. Limit here, would be around 5-10 clients

if more clients, have subdomains for each client. I would then have a middleware on all my routes, to get the subdomain I am on and then set a $connection variable. This way, for this request, all my queries would use only this connection.

mushood left a reply on Using Controller To Open New Window For Redirect

If you are using only php, then the way you did it so far is correct. But if you are using JS/Vue, it would be better to send an ajax request instead of redirecting. Send an ajax request to get the link and then open the link in a new window.

mushood left a reply on Create An Up To Date Feed

What you have right now are three collections. You can use the merge function to add them together. https://laravel.com/docs/5.8/collections#method-merge

Once they are merged, you can then order them by the created_at field if all of them have it. https://laravel.com/docs/5.8/collections#method-sortby

$merged = $newsReply->merge($newsOpportunity);
$merged = $merged->merge($newsComment);

$sorted = $merged->sortByDesc('created_at');

mushood left a reply on Create An Up To Date Feed

Yep.

I dont really see any way to do this simpler.

You fetch 3 different models and then place them in an array. Maybe you can share what you are doing after with the array and so on. But if thats how far you are going, then i guess that's it. One further suggestion would be to create an associative array instead:

$array['reply'] = ....;
$array['opportunity'] = ....;
.
.
.

That way you dont need to remember which one is first or second.

mushood left a reply on Route With Already Predefined Variable

you can retrieve the url like this, in your controller

public function(Request $request)
{
$url = $request->url();
}

you can explode the url with delimeter '/'

Then you check the first value to know if it is domains or contact

03 Jun
1 month ago

mushood left a reply on Share Data Between Views And Causes Migration Error

Try this

view()->composer('*', function ($view) {
            $view->with([
                'all_users' => User::mostActive()->where('active', '=', 1)->get()->pluck('full_name_company_email', 'id'));
            ]);
        });

mushood left a reply on How To Make Reports With DateTime Data?

Laravel uses the Carbon library to deal with dates: https://carbon.nesbot.com/docs/

If you want to use the template for printing PDF, I would suggest using: https://github.com/barryvdh/laravel-dompdf

Create a blade template and use the package to load this view directly.

mushood left a reply on How To Set Queued Email Tries?

Check this section from the documentation

https://laravel.com/docs/5.8/mail#queueing-mail

As you can see, you can implement the ShouldQueue interface OR you can queue the email when sending.

use Illuminate\Contracts\Queue\ShouldQueue;

class TextAndButtonEmail extends Mailable, ShouldQueue
{

public $tries = 5; //for example
02 Jun
1 month ago

mushood left a reply on Beginner Routes And Controllers Query

Hello

First off, don't apologize for not knowing everything or feeling bad for being a beginner. We all started here and this forum is meant to help each other. You'll love this framework soon enough.

There are several ways to tackle your problem and the correct solution is "it depends on your project"

Route::resource('projects/{project}/tasks', 'ProjectTasksController');
Route::resource('clients/{client}/tasks', 'ClientTasksController');

could become either

Route::resource('project_tasks', 'ProjectTasksController');
Route::resource('client_tasks', 'ClientTasksController');

In your command line, run this

php artisan route:list

you will see all the routes available in your project

Example:

// in my route file: Route::resource('shop', 'ShopController');

 | web  | GET|HEAD  | shop                                   | shop.index              | App\Http\Controllers\[email protected]                              | web                          |
|        | POST      | shop                                   | shop.store              | App\Http\Controllers\[email protected]                              | web                          |
|        | GET|HEAD  | shop/create                            | shop.create             | App\Http\Controllers\[email protected]                             | web                          |
App\Http\Controllers\[email protected]                            | web                          |
|        | PUT|PATCH | shop/{shop}                            | shop.update             | App\Http\Controllers\[email protected]                             | web                          |
|        | GET|HEAD  | shop/{shop}                            | shop.show               | App\Http\Controllers\[email protected]                               | web                          |
|        | GET|HEAD  | shop/{shop}/edit                       | shop.edit               | App\Http\Controllers\[email protected]                               | web                          |

As you can see the "resource" give you six routes. In your code, you will have routes that will clash since you have a dynamic property. I would suggest not to add dynamic properties to your route. It just confuses your further especially when you come back to the project later.

I like the principle that a few lines is better than a single line for code but when you come back to the project, you don't even know what this line is doing. Keep it simple.

Another way you can tackle this is, if you logic is similar

Route::resource('tasks', 'TasksController');

Then send it a parameter in your post or get request to determine if the type of task you are dealing with.

Hope this helped and happy learning! :D

mushood left a reply on How To Set Queued Email Tries?

The count is more for the queue than for the jobs. Since you can queue your emails, you can set count for mail send tries as well.

Can you provide more details on what you want to do and associated code?

30 May
1 month ago

mushood left a reply on Vue Component Is Not Displaying

The div with id app needs to be inside the body

<div id="app">
    <body>
 <body>.
    <div id="app">

mushood left a reply on Vue Component Is Not Displaying

@webfabricant , please copy paste FULL blade pages. Not only the concerned section. The issue seems to be with your templating.

So post FULL page where you use the component and FULL base page ie. layouts/app.blade.php

29 May
1 month ago

mushood left a reply on Vue Component Is Not Displaying

On this page where you have your component

@section('content')
    <vue-login></vue-login>
@endsection

Do you have a div with id 'app'. Like this:

@section('content')
<div id='app'>
    <vue-login></vue-login>
</div>
@endsection

mushood left a reply on Laravel 419 Error When Enable Mod_headers For Apache

@surandra Not really sure why it does not work when mod_headers is turned on. I have tried it on my side and it works correctly.

Can you test this on fresh laravel app? Maybe the issue comes elsewhere.

28 May
1 month ago

mushood left a reply on Could Not Find Driver Laravel 5.8.17 & PHP 7.2.17

Can you post the full stack trace of the error.

Did you site work BEFORE running "php artisan migrate:fresh --seed"

mushood left a reply on Laravel Framework Storage Permission

The better solution would be to give your application permission to write to this file by assigning it the right user group.

Here is the full explanation: https://stackoverflow.com/questions/30639174/how-to-set-up-file-permissions-for-laravel-5-and-others

mushood left a reply on How To Change Title With Vue

Try to use a computed property

<template>
    <div class="p-2">
        <button @click="toggle" class="bg-grey-light text-grey-darker rounded-full px-4 py-2" v-on-clickaway="hide">{{title}}</button>

        <div v-if="active" class="w-64 bg-white shadow-md rounded p-4 mt-2 absolute z-20">
            <ul class="list-reset">
                <li class="mb-3">
                    <a href="/fréttir?vinsælt=1">Vinsælt</a>
                </li>
                <li>Homi</li>
            </ul>
        </div>
    </div>
</template>

<script>
    import { mixin as clickaway } from 'vue-clickaway';

    export default {
        mixins: [ clickaway ],

        data() {
            return {
                active: false,
                title: ""
            }
        },
      
      computed: {
        title: function () {
var title = "default";
      // have your condition
if (condition) {
title = "asdf"
}
      return title;
    }
            },

            show() {
                flash("já");
                this.active = true;
            },

            hide() {
                flash("nei");

                this.active = false;
            }
        }   
    }
</script>

Doc: https://vuejs.org/v2/guide/computed.html

mushood left a reply on User Id

Consider using roles

Maybe this package can help: https://github.com/spatie/laravel-permission

mushood left a reply on Vue Component Is Not Displaying

To help you better, post the code of the blade file for homepage

Make sure you have something like this

<div id='app'>

<component></component>

</div>

mushood left a reply on Help Regarding My Blade File

Here's how you can counter that:

In your blade file

//this will pass the user to the component ONLY if logged in
<component

@if(Auth::check())
        :user="{{ Auth::user() }}"
@endif
></component>
    

Then in your vue file

//You can set the prop to not required and also set a default value
props: {
            user: {
                required: false,
                default: false
            },
        },

Hence you will not have this error: I get a error about the prop can not be empty AND no need to encode this in window

mushood left a reply on Puzzling Phenomenon

While I dont have the answer, in browser, the request enters via the public/index.php.

/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/
$app = require_once __DIR__.'/../bootstrap/app.php';

/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/

$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);

whereas for the test, it starts in tests/CreateApplication.

    /**
     * Creates the application.
     *
     * @return \Illuminate\Foundation\Application
     */
    public function createApplication()
    {
        $app = require __DIR__.'/../bootstrap/app.php';

        $app->make(Kernel::class)->bootstrap();

        return $app;
    }

Both open the Kernal class.

However there are two different Kernel to take into account.:

  1. The app/Http/Kernel.php

  2. vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php

1 extends 2, if i am not mistaken. In 1, there is a middleware priority, which defines clearly which one to load first. In this one, you can see that Session comes before authenticate.

if you check app.config, you will see that in the providers array, authenticate comes first and then session

I believe the answer lies somewhere within, but sleep calls. Digging in the vendor files sure is fun. Keep this thread updated if you do find the answer

mushood left a reply on Laravel 419 Error When Enable Mod_headers For Apache

As you sending the CSRF Token in your POST requests? I believe the answer to this to be Yes, since it works when you disable mod_headers.

Can you post the code of an example post request? It maybe you that you have to send additional headers in your request when you turn mod_headers on.

You could alternatively disable CSRF token in your VerifyCSRF middleware

 protected $except = [
        'post route'
    ];

mushood left a reply on Help Regarding My Blade File

Why not pass this information as props to a component?

mushood left a reply on Which Editor Do You Use To Work?

Phpstorm all the way!

mushood left a reply on Laravel On OVH Shared Hosting

Hello

I don't have actual experience with OVH personally, but I once worked with a client who had the site hosted on OVH. I was able to run composer and git.

Personally I use bluehost shared hosting and it is pretty decent. Git, Composer, HTTPS with lets encrypt now. Customer Chat service is great. Though you have to wait around 10 mins with customer service, most of their response and guide is more or less okay.

mushood left a reply on API Development

@afoysal Is your app loading in the browser at least? If it is not, then the problem is with your installation on the server.

Did you try this in local development to see if you have the same error 500?

23 May
1 month ago

mushood left a reply on Data Shows In Console, But Not In The View

created() {
            const vm = this;
            axios.get('./api/admin')
            .then(response => vm.clients = response.data.data);
        },

I want to explain this part but I dont have the clear words to actually do so,I would suggest watching the Vue 2 step by step video. Basically its about the keyword "this" in JS. The this in the axios promise is not the same this as outside the promise where your clients exist.

22 May
1 month ago

mushood left a reply on Data Shows In Console, But Not In The View

@wallyj

in your controller, return a json response

return response()->json(compact('user','clients'));

now in your axios then promise

methods: {
            loadUsers() {
const vm = this;
                axios.get("api/user").then(({ data }) => (vm.users = data.user));
            }

mushood left a reply on Open Source Real World Laravel Projects?

@devfrey Spot on. In the beginning of this project, most of them were open-source. Nevertheless, quite a few of them still are :)