oroalej

Experience

2,390

0 Best Reply Awards

  • Member Since 4 Months Ago
  • 11 Lessons Completed
  • 0 Favorites

12th June, 2018

oroalej started a new conversation Library For Point And Reward System. • 1 week ago

Can you guys recommend a point and reward system library for laravel if you know any.

We would like to add a point and reward system where a user will be rewarded with points whenever he/she answer a question and that point can be converted to something (reward).

oroalej left a reply on Laravel Datatable • 1 week ago

change your ajax to

  ajax: {
      url: route('teachers.data')
    },

Please make sure that you are calling the correct name.

you can check it using php artisan route:list --name=teachers.data

oroalej left a reply on How To Calculate The Total Likes Of All Posts Of A User • 1 week ago

Try using withCount.

you can read further in here

oroalej left a reply on How To Calculate The Total Likes Of All Posts Of A User • 1 week ago

request()->user()->withCount('postLike');

You should have a relationship with user and postLikes to make it work.

then laravel will create `post_like_count` column.

You can read further in (here)[https://laravel.com/docs/5.6/eloquent-relationships#counting-related-models]

11th June, 2018

oroalej left a reply on How To Create A New Function In Resource Controller In Laravel? • 1 week ago

create a function in the controller then add it in the route.

Route::get('purchase_detauls/newFunction', [email protected]');
Route::resource('Purchase_details','Purchase_detailsController');

or you can enclose it in Route::group

30th May, 2018

oroalej left a reply on How To Use V-for Index Inside Formcollective • 3 weeks ago

@click Thank you very much bro!

29th May, 2018

oroalej left a reply on How To Use V-for Index Inside Formcollective • 3 weeks ago

@bobbybouwmann I also tried using question[{{ index }}][answers][1] but it also doesn't work, it says undefined index. when I add @{{}}, it just printed out the whole {{ index }}

28th May, 2018

oroalej started a new conversation How To Use V-for Index Inside Formcollective • 3 weeks ago

Is it possible to use v-for index inside formcollective?

Here is an example:

      <div v-for="(question, index) in questions" style="margin-top: 20px">
          {{ Form::text('question[@{{index}}][answers][1]', null, ['class' => 'form-control']) }}

I want to add the index of v-for as the array index in the attribute name.

oroalej started a new conversation Is Request() Is Still Working When The Route Is Accessed Using Android? • 3 weeks ago

Hi,

We have an android application where the user can login, the problem is that it seems like the login is not going through or the request() doesn't return anything. But when I try checking the calls using Postman, everything is working fine.

25th May, 2018

oroalej left a reply on Need Tips On How To Handle Form Spam Submit • 3 weeks ago

@tomopongrac I already did that, is there any other way? because if the user disable the javascript or remove the disabled attribute using inspect, he can spam submit again.

@Snapey It's like an inquiry/messaging type of functionality. What captcha package can you recommend, /captcha or /no-captcha?

oroalej started a new conversation Need Tips On How To Handle Form Spam Submit • 3 weeks ago

Hi,

How can you guys handle form multiple submit / spam submit? I have a problem that when a user click the submit button repetitively, it will save in the database multiple times.

24th May, 2018

oroalej left a reply on How To Add Delay On @click To Prevent Multiple Click • 3 weeks ago

@m-rk Thanks bro.

oroalej started a new conversation How To Add Delay On @click To Prevent Multiple Click • 3 weeks ago

Hi,

The title say it all.

The @click is for a like button. I just want to prevent the double clicking.

21st May, 2018

oroalej left a reply on How To Get Client Ip Address In Register Controller In Laravel 5.3 With Passport Enabled • 4 weeks ago

You can also use request()->ip()

10th May, 2018

oroalej started a new conversation Purpose Of Builder Query • 1 month ago

Hi,

Just want to ask what is the purpose of Builder in

$model::when(condition, function(Builder $query){
    $query->someCondition;
})->get();

Because sometimes I get an error using it and by removing it fixed the issue.

6th May, 2018

oroalej started a new conversation Japanese Translation Of Validation • 1 month ago

Is there an existing japanese translation of laravel's validation?

30th April, 2018

oroalej left a reply on Auth Check Two Columns • 1 month ago

@tykus SPOT ON! thank you bro!

oroalej started a new conversation Auth Check Two Columns • 1 month ago

Is it possible to check two columns when authenticating? I would like to create a table with email and username columns whereas username is from the email address without the @gmail.com. and user can login using email or the username.

Really appreciate your help.

25th April, 2018

oroalej left a reply on Union With Pagination - Laravel 5.6 • 1 month ago

Hi guys,

I was able to make it in one query. But I still want to know how to make it work in case I encounter this problem in the future.

Thank you for your time @biishmar and @Agelios

oroalej left a reply on Union With Pagination - Laravel 5.6 • 1 month ago

@Agelios

Here is the code

  $featuredProfessionals = Professional::select('name', 'id')
                          ->WhereNotNull('matterport_url')
                          ->where('name', 'LIKE', "%{$search}%")
                          ->where('featured_ends_at', '>=', now());

  $professionals = Professional::select('name', 'id')
                        ->WhereNotNull('matterport_url')
                        ->where('name', 'LIKE', "%{$search}%")
                        ->union($featuredProfessionals)
                        ->latest()
                        ->paginate(5);

oroalej left a reply on Union With Pagination - Laravel 5.6 • 1 month ago

@Agelios I tried adding select to both queries, but it only works when I select 1 column. When I select 2 or more columns, the error showed up again.

@biishmar Like I said, it is working fine if I remove the ->union() code.

Sample code:

$first = Professionals::SomeConditions
                ->limit(5);

$second = Professional::SomeConditions
                    ->union($first) <<<--- If i remove this, everything is working fine.
                    ->paginate(5);
                    

$first = I'm trying to get only the featured professional where featured_date >= today.

$second = I'm trying to get the latest professional and combining the result with $first.

oroalej left a reply on Union With Pagination - Laravel 5.6 • 1 month ago

@biishmar Everything is working fine when I didn't use ->paginate(), but when I do, the error appear. It seems like paginate is not working with union. Is there any work around?

oroalej started a new conversation Union With Pagination - Laravel 5.6 • 1 month ago

Hi Guys,

How can I add pagination on a union. I got an error Cardinality Violationwhen using union with ->paginate().

20th April, 2018

oroalej started a new conversation Handle Sidebar State (If It Is Minimized Or Not) • 2 months ago

Hi guys,

What is the best way to handle the state of the sidebar? For example, if i minimized and refresh the page. the sidebar should be still minimized.

18th April, 2018

oroalej left a reply on Adding New Route To A Route:resource Returns Blank Page To The Route • 2 months ago

Try php artisan route:list to check if you are calling the right route.

oroalej started a new conversation Models Events • 2 months ago

Hi guys,

I'm trying to learn how we can manipulate the events on models. Can you give me any article/video that explain it clearly that is for free.

Really appreciate it. Thanks!

14th April, 2018

oroalej left a reply on How To Use Eloquent API Resource • 2 months ago

@bwrice oh, if I try to add it in my view just like this,

return view('someview', compact('$revision'); it will also not triggered the toArray() method?

oroalej left a reply on How To Use Eloquent API Resource • 2 months ago

@rin4ik What's the different that it will make? when I dd($blog) even when using the (Blogs $blog) it output the target blog.

oroalej started a new conversation How To Use Eloquent API Resource • 2 months ago

Hi Guys,

This is my first time using Resource and I really don't know how to use it. I'm stuck for hours trying to make it work so please help me.

Here is my sample code:

Controller:

public function edit(Blogs $blog)
{
  dd(new Revision($blog));
}

Resource:

use Illuminate\Http\Resources\Json\JsonResource;

class Revision extends JsonResource
{
    public function toArray($request)
    {
      return [
        ....
    'date_difference' => 'Some code'
      ];
    }
}

I'm just trying to output add the 'date_differencein the response but I couldn't make it. It seems likeBlogResource` didn't used at all.

11th April, 2018

oroalej left a reply on Find() Not Working Properly • 2 months ago

@Nash I found my issue, I added a ->get() at the end of the code. Modal::find($id)->get().

oroalej left a reply on Find() Not Working Properly • 2 months ago

@tisuchi yes, the id is the primary key of the table and it's an integer

@ztioge primary key is unique, so technically i'm just retrieving one item.

10th April, 2018

oroalej started a new conversation Find() Not Working Properly • 2 months ago

What would be the cause of ::find()to not work? it return all records in the table.

I tried using $model::where('id', '=', (int)$id) and it's working fine.

Is there any rules that we should follow in order for ::find() to function properly?

2nd April, 2018

oroalej left a reply on How To Call Function In An Extends Model • 2 months ago

@rumm.an Takes for pointing out. It seems like this code $files = $this->files->sortBy('width'); returns empty. Gonna test this part tomorrow and update you guys about this.

@Snapey I always saw you reply to problems, thanks for checking this issue.

The return statement I don't understand though... hmm.I'm also not sure about that. But is seems like if one of it is not empty, return the link else return empty string.

oroalej left a reply on How To Call Function In An Extends Model • 2 months ago

@rumm.an sorry, it's a typo. It should be getUrl. the function returns empty string. however, when i try to use the Medium::order(), it return some link.

oroalej started a new conversation How To Call Function In An Extends Model • 2 months ago

Hi,

How can i Access a function in my extends model?

I have a Medium.php model with a function of getURL()

public function getUrl($width = 800): string
    {
        $files = $this->files->sortBy('width');

        $collection = $files->filter(function ($item) use ($width) {
            return $item['width'] >= $width;
        });

        $selected = $files->last();
        if (! $collection->isEmpty()) {
            $selected = $collection->first();
        }

        return empty($selected) || empty($selected->url) ? '' : $selected->url;
    }

Now I created another model named Media.php and extends it to Medium.php (I need to create a new model because we are not allowed to edit in Medium.php) How can I access the getURL in:

    $media = Media::orderBy('order')->get();

    foreach($media as $item){
        dd($item->getURL())
    }

Thanks in advance guys

23rd March, 2018

oroalej left a reply on What Is The Best Plugin/package To Optimize Images • 2 months ago

@Nash

Hi, Thank you for your quick reply.

We already tried the Spatie but it seems like one of their dependency is already deprecated.

Let me check Intervention images.

Thanks!

oroalej started a new conversation What Is The Best Plugin/package To Optimize Images • 2 months ago

Hello,

Do you have any suggestion on any package that can optimize images? Currently, our whole site are using the full quality of the images and sometimes the file size is around 5-10MB, there are already 20k images and it is a pain in the ass if we optimize it one by one.

Your suggestion is greatly appreciated.

Thank you!

22nd March, 2018

oroalej left a reply on Question Regarding Concatenating Assignment Operator In Eloquent Query Builder • 2 months ago

I think you can use When to check for the request();

->join('player_positions', 'nfl_team.team_id', '=', 'players.team_id')
->when($request->has('first_name'), function($query) use ($request){
   $query->where('players.FName', 'LIKE', '%'. $request->first_name.'%');
});

16th March, 2018

oroalej left a reply on Is This The Proper Way Of Adding Records? • 3 months ago

@behnampmdg3 Just to add, please make sure to validate first the request before inserting it in your database.

you can either:

public function store(CreateARequest $request)
{

}

You can learn it here

Or through this

public function store(Request $request)
{
    $validate = $request->validate([
                     'about' => 'required,
    ]);
{

The first one is much easier.

oroalej left a reply on Model Access In Laravel > 5 • 3 months ago

@tykus Thanks men, I learned new things from you.

oroalej started a new conversation Caching A Query Result • 3 months ago

Hi,

What is the best way to cache a query result if the page have a filter option? Do I get all the result and cache it then just manipulate the result from there?

Thank you in advance guys.

1st March, 2018

oroalej started a new conversation Pagination Without ... • 3 months ago

I would like to create a pagination only 1 2 3 4 5 6 7 8. However, when the page is more than 10, the pagination becomes 1 2 3 4 5 6 7 8 ... 9 10. How can i remove the ... 9 10? Is there a way to do this?

17th February, 2018

oroalej started a new conversation How To Use Old() In Multiple Select Without Using Form::select() • 4 months ago

The title already said it all, I was able to retrieve the old form value using the Form::select(). I'm just curious if this is possible in plain html?

Also, How can you validate the multiple select? since we add "[]" to the name of the select when it's multiple, the validation doesn't work in this name. Can you guys guide me on how.

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.