arukomp

arukomp

Member Since 9 Months Ago

Experience Points 20,410
Experience
Level
Lessons Completed 11
Lessons
Completed
Best Reply Awards 28
Best Answer
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.

29 Sep
1 month ago

arukomp left a reply on How To Stop Eloquent Trying To Set Updated_at

You'll often encounter tables where you don't even want to have an updated_at column because you'll never touch the records after their creation. The easiest way (for me at least) to achieve it is this:

  1. Migration. Replace the default $table->timestamps(); call with a new one like this:
$table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP'));

this will continue filling the created_at column automatically and will be handled by MySQL.

  1. Model. Disable the timestamps because you no longer want to rely on Laravel generating the timestamps. Also, you might want to add a $dates cast attribute, just to make sure that the created_at column is always being cast to a Carbon instance.
class SomeModel extends Model
{
    public $timestamps = false;
    
    protected $dates = ['created_at'];
    ...
}
21 Jun
4 months ago

arukomp left a reply on Refresh Page Error

in other words, just replace this

return view('add-interest',compact('id'))->with(['friend_name' =>$request->input('friend_name')]);

with this:

return redirect()->back()->with(['friend_name' =>$request->input('friend_name')]);
20 Jun
5 months ago

arukomp left a reply on Laravel Checkbox After Submit

This validation is confusing me:

$validator = Validator::make($request->all(), [
            'departure_date' => [new CurrentDeparture, 'required', 'date', 'after:yesterday'],
            'location' => 'required|max:1|integer',
            'not_sure' => 'boolean|max:1|min:1'
        ]);

So the not_sure value can only be 1? If it's not 1, then the validation will fail and the user will get an error. So what if the user hasn't selected the option? You'll get a 0 or false

15 Jun
5 months ago

arukomp left a reply on PhpUnit Is Deleting My Database!

I really think this is an environment file issue. I got burned this way a couple of times. The problem was that instead of .env.testing phpunit was using .env which had my development database.

Just double check that you have a .env.testing file and make sure your phpunit.xml is set up properly to use the testing environment

14 Jun
5 months ago

arukomp left a reply on Weird Issue With Laravel Slack Notification

how is this method actually getting the webhook URL for each individual user?

    public function routeNotificationForSlack()
    {
        return 'new_slack_incoming_webhook_url';
    }

arukomp left a reply on Does RefreshDatabase Rollback Changes After Each Test Of At The End Of All

Depends.

If you're using an in-memory database (DB_DATABASE = :memory:) then the trait will refresh the database after each test.

If you're using a normal database, then it will migrate ONCE, and then run your tests within transactions. This is faster than migrating and rolling back after each test individually

arukomp left a reply on Disabling The Csrf For The Login POST Route

perhaps a more friendlier error message for the user?

Sorry, your session has expired! Please try again
13 Jun
5 months ago

arukomp left a reply on Custom Column In Password_resets

I believe this method should look like this:

    public function getEmailForPasswordReset() {
        return Email::find($this->email_id)->email;
    }

or if you have a relationship with the Email class, then it's even easier:

    public function getEmailForPasswordReset() {
        return $this->email->email;
    }
08 Jun
5 months ago

arukomp left a reply on How To Pass DB Array Values To Blade View

it's really hard to help when we don't know the structure of your objects/arrays. Saying only 5th record is having airports array(2 values) remaining all records they have only one doesn't really help us help you.

try to dd($meeting) and give us the response, which has the whole structure of the variable $meeting. That way we can help you figure out how to access the values the way you want them

arukomp left a reply on Passing Data From Blade To Controller Through AJAX

laravel logs? What's the exception? What's the error? Need more info

arukomp left a reply on How To Pass DB Array Values To Blade View

<td>{{ is_string($meeting[0]['airport']) ? $meeting[0]['airport'] : implode(', ', $meeting[0]['airport']) }}</td>

Ideally this kind of logic would be put inside a model's mutator, but just as a hack, the above should work.

arukomp left a reply on How To Pass DB Array Values To Blade View

put this in your blade file and tell us what you get

@php dd($meetings) @endphp

arukomp left a reply on Passing Data From Blade To Controller Through AJAX

Whenever you get a 500 response, look at your laravel logs (they're in storage/logs/laravel.log). That should give you some insight into what went wrong

arukomp left a reply on Always Redirect

make sure the dashboard/change_password page is not part of the middleware.

Otherwise it will keep redirecting to itself

arukomp left a reply on Always Redirect

Create a new middleware, something like CheckForPasswordExpiry, register it in your App\Http\Kernel.php, in the $routeMiddleware, and then surround your routes with this middleware, like so:

Route::group(['middleware' => ['password_expiry_check']], function () {
    Route::get('dashboard/index', function(){
        return view('dashboard/index');
    })->name('dashboard.index');

    Route::get(....);
});

arukomp left a reply on Initial Site Deployment Fails

how are you deploying it? What exactly are you trying to use?

arukomp left a reply on Send Notification

@omarsow94 Looks like your mailable is Queueable, which means it'll be put in the job queue for processing.

Are you running the Laravel queue worker?

php artisan queue:work

arukomp left a reply on Send Notification

what's your mail configuration in your .env file?

arukomp left a reply on GRPC & RabbitMQ

that's great! Let us know how it goes :)

07 Jun
5 months ago

arukomp left a reply on Need Help With Query

    public function scopeSearch($query, $search)
    {
        $query->where('user_id', auth()->id())
            ->orWhere(function ($query) use ($search) {
                $query->whereHas('invitedUsers', function ($query) use ($search) {
                    $query->where('id', $search);
                });
            });
    }

arukomp left a reply on Form Route Is Not Defined

Resource won't work for custom controller methods, plus you're defining it wrong anyway.

Try this instead:

Route::put('profile/{username}', 'UserinfoCo[email protected]')->name('profile.update');
Route::post('profile/{username}/rateUser', '[email protected]')->name('profile.rateUser');
Route::get('profile/{username}', '[email protected]')->name('profile.show');
Route::get('profile/{username}/edit', '[email protected]')->name('profile.edit');

arukomp left a reply on Trying To Get Property 'id' Of Non-object

three backticks ( ) to start with, code in a new line, and then again three backticks ()

arukomp left a reply on Trying To Get Property 'id' Of Non-object

The code above would return all the teams if the user doesn't have a current team. Is that what you intended to do? Doesn't look like it from your original code.

All you really need is just an optional wrapper around the currentTeamin your original code:

return static::where('team_id','=', optional(Auth::user()->currentTeam)->id)
            ->groupBy('mob')
            ->get();
06 Jun
5 months ago

arukomp left a reply on How To Display The Data Using Search By Function In Laravel 5.5 ?

you should be using whereDate instead of where because you're only comparing it to dates, instead of datetimes

arukomp left a reply on Model->increment() Not Working In Middleware

like @Thyrosis said, the only problem I can see here is the fact that either $id is empty/wrong, or the Imov::find($id) isn't finding the model, so it's trying to call the method on null.

do dd(Imov::find($id)) just to see you're actually getting an eloquent model

arukomp left a reply on Scope With Constraint On Latest Entry In Many To Many Relation

your statuses relationship returns ALL of the statuses, not just the latest one, which is why the whereHas is matching in this case.

Try adding another relationship, perhaps called latestStatus to indicate the very latest status.

    public function latestStatus()
    {
        return $this->belongsToMany('App\Models\Status')
            ->withTimestamps()
            ->latest('status_user.created_at')//ordering by the created_at field in the pivot table
            ->limit(1);
    }

the problem with this is that belongsToMany relationship would return a collection of 1 status, instead of the status model itself. That's a bit inconvenient. If it weren't for the pivot table, things would've been a little easier:

    public function latestStatus()
    {
        return $this->hasOne('App\Models\Status')
            ->orderBy('created_at', 'desc');
    }

arukomp left a reply on How To Display The Data Using Search By Function In Laravel 5.5 ?

@AliShahbaz add a backslash in front of Carbon\Carbon, like this:

    return $searchData->where('created_at', '>=', \Carbon\Carbon::create()->subWeek());
05 Jun
5 months ago

arukomp left a reply on How To Display The Data Using Search By Function In Laravel 5.5 ?

use the code I showed you. Or just remove the Request part from the (Request $request)

arukomp left a reply on Handling Incomming Payment Request

In this case, I'd suggest 2 middlewares:

  1. Validate api key/secret - grant/deny access
  2. Convert XML request into regular Laravel Request

The second middleware could be reused in other parts of your application, plus you'll be able to use Laravel's form validation

arukomp left a reply on Handling Incomming Payment Request

have the actual data processing in the controller methods. It makes sense that way because every one of the different payment methods might need slightly different processing, and you really don't wanna have multiple ifelse or switch statements in the middleware.

In this scenario, the middleware's job really is just to validate access (api token/key?).

If you'd like to validate input (required fields, correct data types, etc), then I'd suggest using Form Requests - https://laravel.com/docs/5.6/validation#form-request-validation

arukomp left a reply on Ignore Blank Field On Update

or...

$user->email = $request->input('email, $user->email);
$user->password = $request->has('password') ? bcrypt($request->password) : $user->password;
$user->department = $request->input('department', $user->department);

request()->input($attribute, $default) will default to the second value if the parameter is empty.

arukomp left a reply on How To Display The Data Using Search By Function In Laravel 5.5 ?

don't typehint the arguments to these functions, because obviously you're not passing a Request

private function searchByThisWeek($searchData) {
    return $searchData->where('created_at', '>=', Carbon\Carbon::create()->subWeek());
}
private function searchByThisMonth($searchData){
    return $searchData->where('created_at', '>=', date('Y-m-') .'01');
}  
private function searchByThisYear($searchData){
    return $searchData->where('created_at', '>=', Carbon\Carbon::create()->subYear());
    // if you want the current month, and not the last ~30 days, use this one
    return $searchData->where('created_at', '>=', date('Y-') .'01-01');
}
private function searchByCustomPeriod($searchData){
    // you should have another 2 fields in the form to set the start and end dates for the custom period
    return $searchData->whereBetween('created_at', [ '2018-01-05',  '2018-03-02' ]);
}
04 Jun
5 months ago

arukomp left a reply on Show Undefined Variable In Edit Code

looks like the error is coming from the index method, and the only variable you're passing is departments (plural). What else is inside the allDepartment.blade.php view? Are you looping through the $departments?

arukomp left a reply on About Service Provider In Package Dev

@larafam can't you move the AServiceProvider's logic from boot into `register method?

arukomp left a reply on About Service Provider In Package Dev

So, service provider code that uses other services should always live in the boot method. The register method should only be used for, you guessed it, registering services with the container. Within the boot method, you may do whatever you like: register event listeners, include a routes file, register filters, or anything else you can imagine.

an excerpt from https://laracasts.com/discuss/channels/general-discussion/difference-between-boot-and-register-method

So, in a nutshell:

class AServiceProvider extends \Illuminate\Support\ServiceProvider
{
    protected $wait;

    public function boot()
    {
        // get the other service provider here
    }
}

arukomp left a reply on 301 Moved Permanently On My Colleague's Computer

trying setting up the environment variables, this one in particular:

APP_URL="http://localhost:8888/my-project/public/"

arukomp left a reply on Catch All Controller Function

Route::any('{slug}', '[email protected]');

arukomp left a reply on Hi All After Login,login Username Come Into Display On Next Pages By Using Ssessions How Can We Do It.

Include this in your LoginController.php

    /**
     * The user has been authenticated.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  mixed  $user
     * @return mixed
     */
    protected function authenticated(Request $request, $user)
    {
        session()->put('username', $user->username);
    }

And this in your RegisterController.php

    /**
     * The user has been registered.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  mixed  $user
     * @return mixed
     */
    protected function registered(Request $request, $user)
    {
        session()->put('username', $user->username);
    }

Then in your views/controllers/etc, just use session()->get('username')

01 Jun
5 months ago

arukomp left a reply on Seeding A HasMany Fails With 'Field ... Doesn't Have A Default Value'

of course there is. Give it a value.

class EventsTableSeeder extends Seeder
{
    public function run()
    {
        factory(App\Event::class, 24)->create()->each(function ($u) {
            $u->save();
            $a = App\Activity::create(['activity_type_id' => 1, 'quantity' => 2, 'event_id' => $u->id]);
            $u->activities()->save($a);
        });
    }
}

arukomp left a reply on How To Select In Related Table.

Either

$grants = Grant::whereIn('share_id', $shares->pluck('id'))->get();

Or

$grants = $shares->flatMap(function ($share) {
    return $share->grants;
});

arukomp left a reply on Strange Redis Keys At The Laravel App Redis Server

parameter binding is standard now. It prevents the SQL injection, but you're still storing invalid data in your tables. Later on you'll be retrieving them and possibly displaying them on your website.

If you happen to store post_body as <script src="123.123.123.123/attack.js"></script> in your database and for some reason you then display it in your views using {!! $post_body !!}, you're in some trouble.

You should still sanitize your inputs no matter what. Can't be too careful.

Plus, the original post was mentioning Redis entries, not database. As far as I'm aware, Redis doesn't have any "parameter binding", so you still have to cleanse the data yourself before putting it there.

arukomp left a reply on Looking For Recommandations For A New Laptop

@DanielCL please update the newegg link :D it's now going to a dodgy site

arukomp left a reply on Looking For Recommandations For A New Laptop

I've had a 2015 macbook pro since 2015 and I'll never look back. When time comes for an upgrade, I'll still go for a macbook pro. And it's not because of the brand or the price...

  1. It's the superior build quality.

  2. It's the whole operating system, the environment, abundance of developer-friendly apps and just the fact that it JUST WORKS.

You want a laptop you can pick up and start coding straight away? MacBook Pro.

Get yourself a Windows laptop or an Ubuntu (slightly better) and you'll end up spending time tinkering your settings and troubleshooting PHP/node/whatever other installations.

Bear in mind, most of Development tools/tutorials/materials are aimed at MacOS owners, created mostly by MacOS owners alike. Having a macbook you'll spend less time trying to figure out things like "what's the Windows equivalent of this..." or "but how do I find those settings in Ubuntu?".

  1. Mac computers hold their value for much longer than any other PC out there. Hold on to your macbook for 4-5 years and you'll still get at least 50-60% of your initial purchase value for it, if not more. That being said, you could probably find Windows laptops used much cheaper than brand new ones.

Macs are the number one choice for most of the developers for many good reasons.

Plus, if you're doing mostly web development and not much video editing/3D modeling, do you really care if it's an i7-7700 or an i7-6700?

arukomp left a reply on Allow Facebook But Block Messenger

If they're using it in a browser on Windows machines - there's not much you can do. It's a web app, there's no way to block just a part of it. Either you block all of facebook, or none of it.

Or you can just educate your users not to use the messenger, giving them good reasons why.

arukomp left a reply on Strange Redis Keys At The Laravel App Redis Server

It doesn't. You need to implement your own methods to sanitize input data. If you're expecting a number, you gotta make sure the user entered a number. If it's an email, you better make sure it's a valid email, etc, etc.

arukomp left a reply on Sending Email To Log File In Laravel

You missed a slash between the email and token here:

Route::get('verify/{$email}{$token}','[email protected]');

arukomp left a reply on Sending Email To Log File In Laravel

Make sure the verify_token property is in your $fillables in User.php

class User extends Authenticatable
{
    protected $fillable = [
        ...
        'verify_token',
    ];

    ...
}

arukomp left a reply on Strange Redis Keys At The Laravel App Redis Server

looks like an injection attempt. Don't see why Laravel would attempt to lookup some dodgy ips/addresses.

Better look at validating your input data.

arukomp left a reply on Ecommerce Recently Viewed Products

and don't forget to order by latest it needed :)

Product::whereIn('id', $products)->latest()->take(10)->get()

// or 

Product::whereIn('id', $products)->orderBy('created_at', 'desc')->take(10)->get()
31 May
5 months ago

arukomp left a reply on What Are Some Open Source Packages For ECommerce?

https://getcandy.io/

Still in development though, but looks great so far!