Reputation: 10896
When I want to show a docx icon if a user has uploaded a docx file I receive the following error:
Call to undefined method Illuminate\Database\Query\Builder::getClientOriginalExtension() (View: /home/vagrant/Code/support/local/resources/views/users/ticket.blade.php)
I'm trying it like this:
@foreach($ticket->image as $photo)
@if($photo->getClientOriginalExtension() == 'docx')
<img src="icons/word.png">
@else
<a href="{{ $photo->path }}"><img src="{{ $photo->path }}" alt=""/></a>
@endif
@endforeach
Obviously the getClientOriginalExtension()
is not right. But what should I use instead?
Upvotes: 2
Views: 10671
Reputation: 111859
You should use:
@if (pathinfo($photo->path, PATHINFO_EXTENSION) == 'docx')
instead of:
@if($photo->getClientOriginalExtension() == 'docx')
Upvotes: 6