emfpc

emfpc

Member Since 1 Year Ago

Experience Points
2,170
Total
Experience

2,830 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
2
Lessons
Completed
Best Reply Awards
1
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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.

Level 1
2,170 XP
May
26
1 day ago
Activity icon

Replied to How To Pass Auth::user()->id Using View::share('')

I need to check first if the user that is log in has a picture, if he has a picture i must decrypt that photo. my reason is look for a way to not to do the same function in all of the controller to decrypt the photo.

Activity icon

Replied to How To Pass Auth::user()->id Using View::share('')

It does. When i test the same logic in the web route it works and i have use the same parameter, Auth::user()->staff_profile->id, in other views and it works.

Activity icon

Replied to How To Pass Auth::user()->id Using View::share('')

@michaloravec

<?php

namespace App\Providers;

use Illuminate\Support\Facades\Auth;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\View;
//
use App\Activity;
use App\Ticket;
//
use App\StaffProfile;
use Illuminate\Support\Facades\Storage;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        Schema::defaultStringLength(191);

        $activitys = Activity::all()->sortByDesc('created_at')->take(6);
        $table = Ticket::all();
        
        if(Auth::check()){

            $staff = StaffProfile::findOrFail(Auth::user()->staff_profile->id);
        
            if($staff->staff_pictures == null){
                // return view ('layouts.medflixtemplate',compact('staff'));
                View::share('staff');
            }else{
                $getStaffPicture = Storage::get('public/'.$staff->user->name.'/'.$staff->staff_pictures->p_name);
                // return view ('layouts.medflixtemplate',compact('staff', 'getStaffPicture'));
                View::share(compact('staff', 'getStaffPicture'));
            }
        }
        View::share('activitys', $activitys);
        View::share('table', $table);       
    }

}

The variable $staff is not passing and i'm getting this error:

ErrorException thrown with message "Undefined variable: staff (View: C:\xampp\htdocs\medflix\resources\views\layouts\medflixtemplate.blade.php) (View: C:\xampp\htdocs\medflix\resources\views\layouts\medflixtemplate.blade.php)"
Activity icon

Started a new Conversation How To Pass Auth::user()->id Using View::share('')

Greetings, I am using a template in where there are data that are share in all the views. What i want to do is to be able to pass the current user that is login to be able to display the user picture in the template it works if i hard code the id

        $staff = StaffProfile::findOrFail(1);

        if($staff->staff_pictures == null)
            View::share('staff', $staff);
        }else{
            $getStaffPicture = Storage::get('public/'.$staff->user->name.'/'.$staff->staff_pictures->p_name);
            View::share(compact('staff', 'getStaffPicture'));
        }

i thought in using Auth::user()->id

$staff = StaffProfile::findOrFail(Auth::user()->id)

but i get this error

 ErrorException (E_NOTICE)
Trying to get property 'id' of non-object

Thanks for the help in advance

Activity icon

Awarded Best Reply on Calling Fonts Using Laravel Mix

Found the issue 😊

Activity icon

Replied to Calling Fonts Using Laravel Mix

Found the issue 😊

May
12
2 weeks ago
Activity icon

Started a new Conversation Calling Fonts Using Laravel Mix

My web application uses font's that are in a folder located in the resources dir. Bootstrap and Javascripts are in the same resource dir and works good in laravel mix but i get errors when it tries to display the font of the theme.

Laravel Mix:

mix.styles(
    [
        "resources/asset/vendor/bootstrap/css/bootstrap.min.css",
        "resources/asset/libs/css/style.css",
        "resources/asset/vendor/fonts/fontawesome/css/fontawesome-all.css",
        "resources/asset/vendor/fonts/circular-std/style.css"
    ],
    "public/css/style.css"
);

Error in inspector:

downloadable font: download failed (font-family: "Circular Std Book" style:normal weight:400 stretch:100 src index:1): status=2147746065 source: http://localhost:8000/css/CircularStd-Book.woff

And this is the style.css of the fonts:

/* #### Generated By: http://www.cufonfonts.com #### */

@font-face {
    font-family: "Circular Std Black";
    font-style: normal;
    font-weight: normal;
    src: local("Circular Std Black"),
        url("CircularStd-Black.woff") format("woff");
}

@font-face {
    font-family: "Circular Std Book";
    font-style: normal;
    font-weight: normal;
    src: local("Circular Std Book"), url("CircularStd-Book.woff") format("woff");
}

@font-face {
    font-family: "Circular Std Medium";
    font-style: normal;
    font-weight: normal;
    src: local("Circular Std Medium"),
        url("CircularStd-Medium.woff") format("woff");
}

@font-face {
    font-family: "Circular Std Black Italic";
    font-style: normal;
    font-weight: normal;
    src: local("Circular Std Black Italic"),
        url("CircularStd-BlackItalic.woff") format("woff");
}

@font-face {
    font-family: "Circular Std Bold";
    font-style: normal;
    font-weight: normal;
    src: local("Circular Std Bold"), url("CircularStd-Bold.woff") format("woff");
}

@font-face {
    font-family: "Circular Std Bold Italic";
    font-style: normal;
    font-weight: normal;
    src: local("Circular Std Bold Italic"),
        url("CircularStd-BoldItalic.woff") format("woff");
}

@font-face {
    font-family: "Circular Std Book Italic";
    font-style: normal;
    font-weight: normal;
    src: local("Circular Std Book Italic"),
        url("CircularStd-BookItalic.woff") format("woff");
}

@font-face {
    font-family: "Circular Std Medium Italic";
    font-style: normal;
    font-weight: normal;
    src: local("Circular Std Medium Italic"),
        url("CircularStd-MediumItalic.woff") format("woff");
}

thanks in advance

Apr
27
1 month ago
Activity icon

Started a new Conversation Send Data From Index

I'm a little stuck Got a little table that shows ticket information; here is where i got stuck. Each ticket has a icon near the name so that the admin can hit follow to see the progress of each ticket; the follow feature is in the index page where i show all the user data:

<table class="table mydatatable" id="myTable">
                                              <thead class="bg-light">
                                                <tr class="border-0">
                                                  <th class="border-0">Follow</th>
                                                  <th class="border-0"> # </th>
                                                  <th class="border-0">Paciente</th>
                                                  <th class="border-0">
                                                      Plan Medico
                                                  </th>
                                                  <th class="border-0">
                                                      Status
                                                  </th>
                                                  <th class="border-0">Actividad mΓ‘s reciente</th>
                                                  <th class="border-0">Fecha de solicitud</th>
                                                  <th class="border-0">
                                                      
                                                      Asignado
                                                  </th>
                                                </tr>
                                              </thead>
                                              <tbody>
                                                @foreach ( $tickets as $ticket )
                                                  <tr>
                                                    <td>
                                                      
                                                      @if (Auth::user()->following->contains('ticket_id',$ticket->id))
                                                        <a role="button" class="btn btn-link btn-lg" href="javascript:unfollowTicketFunction()">
                                                          <span style="color:#f6e58d;">
                                                          <i class="fas fa-star"></i>
                                                          <input type="text" id="inputTD" value="tickets/{{ $ticket->id }}" >
                                                        </a>
                                                       Following
                                                      @elseif(Auth::user()->name == $ticket->assigned_user)
                                                        <span style="color:#f6e58d">
                                                          <i class="fas fa-star"></i>
                                                        </span>
                                                      @else
                                                        <input type="text" id="inputT" value="tickets/{{ $ticket->id }}" onclick="followTicketFunction()">
                                                       
                                                          <span style="color:#f6e58d;">
                                                            <i class="far fa-star"></i>
                                                          </span>
                                                        <p onclick="followTicketFunction()">Follow</p>
                                                                                                               
                                                      @endif
                                                      {{--    --}}
                                                    </td>
                                                    <td> 
                                                        <a href="tickets/{{ $ticket->id }}">{{ $ticket->ticket_number }}</a>
                                                    </td>
                                                    <td>{{ $ticket->userprofile->user->name }}</td>
                                                    <td>{{ $ticket->userprofile->user->medical_plan->first()->plan_name }}</td>
                                                    <td>
                                                        {{ $ticket->status }}
                                                    </td>
                                                    <td>{{$ticket->activities->first()->description}}</td>
                                                    <td>{{ $ticket->created_at }}</td>
                                                    <td>{{ $ticket->assigned_user}}</td>
                                                  </tr>
                                                @endforeach
                                              </tbody>
                                                <tfoot>
                                                  <tr class="border-0">
                                                    <th class="border-0">Favoritos</th>
                                                    <th class="border-0"> # </th>
                                                    <th class="border-0">Paciente</th>
                                                    <th class="border-0">
                                                        Plan Medico
                                                    </th>
                                                    <th class="border-0">
                                                        Status
                                                    </th>
                                                    <th class="border-0">Actividad mΓ‘s reciente</th>
                                                    <th class="border-0">Fecha de solicitud</th>
                                                    <th class="border-0">
                                                        Asignado
                                                    </th>
                                                  </tr>
                                                </tfoot>
                                            </table>

currently i am tryint to use javascript to send the data into the form:

<form method="post" action="" id="myFollowTicketForm">
    <input type="hidden" name="_method" value="PUT">
    {{ csrf_field()}}

    <input type="text" value="20" name="action" id="action" hidden>
    </form>

if i put in the action on the form where i am sending the data manually it works but can't see to find a way to just click the ticket and send it. is there a better practice for this?

all of my controller are the following

Route::resource('tickets', 'TicketController');

my apologies for the confusion thanks in advance

Feb
10
3 months ago
Activity icon

Replied to Search Like Bar Using Ajax

sorry for the late reply @ahmeddabak πŸ™‡β€β™€οΈ User Profile Model:


namespace App;

use Illuminate\Support\Facades\Crypt;
use Illuminate\Database\Eloquent\Model;
use Carbon\Carbon;

class UsersProfile extends Model
{
    protected $fillable = [

        'user_id',
        'user_type',
        'first_name',
        'initial',
        'last_name',
        'maternal_lastname',
        'birthdate',
        'sex',
        'phone',
        'alt_phone',
        'identification',
        
    ];

    public function user(){
        return $this->belongsTo('App\User');
    }

    public function getIdentificationAttributes($value){
        return Crypt::decrypt($value);
    }

    public function getPhoneAttributes($value){
        
    }

    public function ticket(){
        return $this->belongsTo('App\Ticket');
    }

    public function getBirthdateAttribute($data){
        
        $age = Carbon::create($data)->diff(Carbon::now())->format('%y');
        return $age;
        
    }
    

User Profile Migration

 public function up()
    {
        Schema::create('users_profiles', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('ticket_id')->nullable();
            $table->integer('user_id')->nullable();
            $table->string('user_type')->default('GUEST');
            $table->string('first_name');
            $table->string('initial')->nullable();
            $table->string('last_name');
            $table->string('maternal_lastname');
            $table->date('birthdate');
            $table->char('sex',1);
            $table->char('phone',20);
            $table->char('alt_phone',20)->nullable();
            $table->string('identification',256);
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users_profiles');
    }
Feb
06
3 months ago
Activity icon

Replied to Search Like Bar Using Ajax

@ahmeddabak the first_name is saved on the userprofiles

Activity icon

Replied to Search Like Bar Using Ajax

@ahmeddabak

I receive no data. If I had this line

'.$ticket->userprofile->first_name.'

the table shows no data what so ever, if i remove it then it will show the ticket number

Activity icon

Replied to Search Like Bar Using Ajax

@ahmeddabak The funny thing is that the relationship works outside of my search logic. Here is the Ticket model:

class Ticket extends Model
{
    protected $fillable = [

        'ticket_number',
        'assigned_user',
        'service',
        'medical_order',
        'status',
    ];

    use Sortable;
    public $sortable = ['ticket_number', 'assigned_user', 'status'];

    public function user(){
        return $this->hasOne('App\User');
    }

    public function userprofile(){
        return $this->hasOne('App\UsersProfile');
    }

    public function ticket_comments(){
        return $this->hasMany('App\TicketsComment');
    }
    public function activities(){
        return $this->hasMany('App\Activity')->orderBy('created_at', 'desc');
    }
    
    public function medical_plan(){
        return $this->hasMany('App\MedicalPlan');
    }

    public function following(){
        return $this->hasMany('App\Follow');
    }

    public function file(){
        return $this->hasMany('App\File');
    }

    public function getCreatedAtAttribute($date){
        return Carbon::parse($date)->format('m/d/y h:m s');
    }

    public function getFileTwo($data){
        return 'fun'.$data;
    }





}
Activity icon

Started a new Conversation Search Like Bar Using Ajax

Greetings,

Thanks to a tutorial i was able to make a live search feature in laravel using ajax. I made a few changes and decided to call the data using Eloquent: Tutorial way:

$data = DB::table('tickets')->where('ticket_number', 'like', '%'.$query.'%')->get();

My changes:

$data = Ticket::where('ticket_number', 'like', '%'.$query.'%')->get();

The reason I'm using eloquent is because i need to access a relationship but i don't know why it won't work. Can access information but if i try to call a relationship it won't work. This is the main code:

function search(Request $request)
    {
        if($request->ajax())
        {
            $output = '';
            $query = $request->get('query');
            if($query != '')
            {
               
                $data = Ticket::where('ticket_number', 'like', '%'.$query.'%')->get();
                    
            }
            else
            {
                $data = DB::table('tickets')->orderBy('id')->get();    
            }

            $total_row = $data->count();
            if($total_row > 0)
            {
                foreach($data as $ticket)
                {
                    $output .= '
                    <tr>
                        <td>
                            <a href="tickets/'.$ticket->id.'">
                            '.$ticket->ticket_number.'
                            </a>
                        </td>
                    </tr>
                    ';
                }
            }
            else
            {
                $output = '
                    <tr>
                        <td align="center" colspan="5">No Data Found</td>
                    </tr>
                ';
            }
            $data = array(
                'table_data'  => $output,
                'total_data'  => $total_row
            );

        //   $data2nd = array('table_data2nd' => $output2nd);

            echo json_encode($data);
        }
    }

if i tried to get the data like this:

$output .= '
                    <tr>
                        <td>
                            <a href="tickets/'.$ticket->id.'">
                            '.$ticket->userprofile->first_name.'
                            </a>
                        </td>
                    </tr>
                    ';

it won't work.

Thanks in advance

Jan
20
4 months ago
Activity icon

Awarded Best Reply on Same Data Entry For Multiple Users

Fixed it πŸ˜„. Was not starting the $read = new Read() at the beginning of the for.

for ($i=0; $i < $ticket->following->count() ; $i++) 
{ 
    $read = new Read;
        $read->activity_id = $activity->id;
        $read->user_id = $ticket->following[$i]->user_id;
        $read->didYouReadIt = '0';
        $read->save();
}

Thanks

Activity icon

Replied to Same Data Entry For Multiple Users

Fixed it πŸ˜„. Was not starting the $read = new Read() at the beginning of the for.

for ($i=0; $i < $ticket->following->count() ; $i++) 
{ 
    $read = new Read;
        $read->activity_id = $activity->id;
        $read->user_id = $ticket->following[$i]->user_id;
        $read->didYouReadIt = '0';
        $read->save();
}

Thanks

Activity icon

Started a new Conversation Same Data Entry For Multiple Users

Greetings,

Every time a activity is created a read data is also created. Each read data must represent a user that is following a ticket, this is what i am try to do:

for ($i=0; $i < $ticket->following->count() ; $i++) { 
    $read->activity_id = $activity->id;
        $read->user_id = $ticket->following[$i]->user_id;
    $read->didYouReadIt = '0';
    $read->save();
}

It only create one read entry and with the current log in user. Each user must have a read; I am testing 3 user that is following a ticket.

Thanks in advance πŸ™‡β€β™€οΈ

Jan
06
4 months ago
Activity icon

Replied to Small Array Question

It worksπŸ™Œ thanks @nakov

@if (Auth::user()->following->contains('ticket_id',$ticket->id))
Your following this ticket
@else
Your not following this ticket
@endif
Activity icon

Replied to Small Array Question

I can use Name or the id. None of the users have the same name

Activity icon

Started a new Conversation Small Array Question

Greetings,

Here is my following issue: I have what is called a Ticket that have information. A log in user can follow multiple Ticket to see how there are handle. now, i can make tell when a user is following a ticket but since i have to do a small "for" to see if the current user is following the ticket; is always displaying the default answers that is not following since i'm checking all the user table.

@for ($i = 0 ; $i < $ticket->following->count() ; $i++)

    @if (Auth::user()->name == $ticket->following[$i]->user->name)
        Your following this ticket {{ $ticket->following[$i]->user->name }}
    @else
        Your are not following this ticket
    @endif
    
@endfor

//$ticket->following shows all the users that are following the ticket

all i need is to just check if the current user is following, if is not following then have the option to follow.

Dec
23
5 months ago
Activity icon

Replied to Queuing Email From Model

i think you need to use a " for " statement since is readying a array of data.

Activity icon

Replied to Passing Data To A Link To A Route

It did work. change some variable names and remove the file name so it looks short. Thanks @nakov 😁

Activity icon

Started a new Conversation Passing Data To A Link To A Route

Greetings, This is what i am trying to do. Have a list of files that will display in the view using a foreach statement; each data will have a img and the name of the file $file->file_url. i want to pass the name of the file and the id of table when i press to call a route to display the pdf file:

View code:

@foreach ($ticketFile as $file) 
    <div class="col">
    <a href="{{ url('document')}}">
        <img width="150" height="100" class="img-thumbnail" height="" src="{{ URL::asset('pdfIcon.png') }}" alt="" />
        <p>{{ $file->file_url }}</p> 
    </a>
@endforeach

Route code:

Route::get('document',function($id, $filename){

        $ticket = Ticket::findOrFail($id);
        $file = Crypt::decrypt(Storage::get('public/Ticket #' . $ticket->ticket_number. '/' . $filename)); 
        $response = Response::make($file,200);
        $response->header('Content-Type', 'application/pdf');
        return $response;

});

If some have a better approach let me know; already tried a forum technique and did not work
Dec
20
5 months ago
Activity icon

Awarded Best Reply on Auth()->check() In Service Provider Returns False

try:

use Illuminate\Support\Facades\Auth;

above your class and i think is:

dd(Auth::check());
Dec
19
5 months ago
Activity icon

Awarded Best Reply on Error "is_file() Expects Parameter 1 To Be A Valid Path, String Given" When Trying To Get A Pdf File

Found the issue. Turns out File::get is the the same as Storage::get and i was using both😐. Thanks for the reply @alishahuk fix code:

    $ticketFile = $ticket->file->where('category','doc');
        $file = Crypt::decrypt(Storage::get('public/Ticket #' . $ticket->ticket_number. '/' . $ticketFile[2]->file_url)); 
        $response = Response::make($file,200);
        $response->header('Content-Type', 'application/pdf');
        return $response;
Activity icon

Replied to Array Logic Help

thanks @bobbybouwmann it works. now got another issue. Need to make that iframe a link to call a response to the file. the response works but i need to pass a argunemtn in the href:

<a href="/document">

</a>

need to pass a the $ticket->id to:

public function getFile($data){

        $ticketFiles = $data->file->where('category','doc');
        $file = Crypt::decrypt(Storage::get('public/Ticket #' . $data->ticket_number. '/' . $ticketFiles[1]->file_url)); 
        $response = Response::make($file,200);
        $response->header('Content-Type', 'application/pdf');
        return $response;
       
    }

this is where i am stuck now

Activity icon

Replied to Error "is_file() Expects Parameter 1 To Be A Valid Path, String Given" When Trying To Get A Pdf File

Found the issue. Turns out File::get is the the same as Storage::get and i was using both😐. Thanks for the reply @alishahuk fix code:

    $ticketFile = $ticket->file->where('category','doc');
        $file = Crypt::decrypt(Storage::get('public/Ticket #' . $ticket->ticket_number. '/' . $ticketFile[2]->file_url)); 
        $response = Response::make($file,200);
        $response->header('Content-Type', 'application/pdf');
        return $response;
Activity icon

Replied to Don't Know Why This Error Is Showing

can you share the code please?

Activity icon

Replied to How To Display File In Laravel

Maybe this will help: https://scotch.io/tutorials/understanding-and-working-with-files-in-laravel

Also in your img tag i think your missing the URL::asset:


<img src="{{URL::asset('PG/doc/'.$docs->user_id.'/'.$docs->multipledoc->multiple_doc)}}" height="50px" width="50px">

Activity icon

Replied to Auth()->check() In Service Provider Returns False

try:

use Illuminate\Support\Facades\Auth;

above your class and i think is:

dd(Auth::check());
Activity icon

Replied to Auth()->check() In Service Provider Returns False

Did you already register a user?

Activity icon

Started a new Conversation Error "is_file() Expects Parameter 1 To Be A Valid Path, String Given" When Trying To Get A Pdf File

Greetings Laracast, in the following code i am testing a way to get my pdf file from storage and view it in the web browser

public function testfile(){

        $ticket = Ticket::findOrFail(1);
        
        $ticketFile = DB::table('files')->where('file_url','like','#'.$ticket->ticket_number.'%')->get();
        $file = Crypt::decrypt(Storage::get('public/Ticket #' . $ticket->ticket_number. '/' . $ticketFile[0]->file_url)); 
        $file = File::get($file);
        $response = Response::make($file,200);
        $response->header('Content-Type', 'application/pdf');
        return $response;
    }

I'm getting the following error:

is_file() expects parameter 1 to be a valid path, string given

can't seem to find a way to fix it.

thanks for the help in advance.

Dec
17
5 months ago
Activity icon

Started a new Conversation Array Logic Help

Goal: decrypt a list of files in a view.

I am able to decrypt and view files the problem i am facing is that i have used it when calling the file directly now i have a list of file in the same table. This is what i am using:

    $ticketFile = DB::table('files')->where('file_url','like','#'.$ticket->ticket_number.'%')->get(); //I have 2 file to see
        $getFile = Storage::get('public/Ticket #' . $ticket->ticket_number. '/' . $ticketFile[1]->file_url);
        $decryptFile = Crypt::decrypt($getFile);
    return view('fieltest', compact('decryptFile');

Like this i am able to see the file in the web page:

<iframe src="data:application/pdf;base64,{!! base64_encode($decryptFile) !!}" />

i want to see the 2 files or more when they keep adding up. I think i need to use some kind of array logic or for or foreach but i am stuck when i need to get the file in the Storage::get.

Thanks in advance

Activity icon

Awarded Best Reply on Decryp File (pdf, Etc)

Got it. Instead of

data:image

I need to use

data:application/pdf

Thanks

Activity icon

Replied to Decryp File (pdf, Etc)

Got it. Instead of

data:image

I need to use

data:application/pdf

Thanks

Dec
15
5 months ago
Activity icon

Started a new Conversation Decryp File (pdf, Etc)

I have been using this guide to encrypt images: https://stefanzweifel.io/posts/how-to-encrypt-file-uploads-with-laravel/

playing around this i made this to my controller:


    $cardImg2 = $request->file('card_img2nd');
        $cardImg2Content = $cardImg2->get();
        $cardImg2Encrypt = Crypt::encrypt($cardImg2Content);
        $medicalplan->card_img = $ticket->ticket_number . '#' . $completname . ' SECUNDARIO';
        Storage::put($uploadPath . $medicalplan->card_img, $cardImg2Encrypt);

The implementation works great when i need to get the image and send it to a view :

 $getMedicalCard = Storage::get('public/Ticket #' . $ticket->ticket_number . '/' . $ticket->medical_plan[0]->card_img);
 $decryptMedicalCard = Crypt::decrypt($getMedicalCard);

return view('test',compact('decryptMedicalCard'));

to see it in blade

<img width="300" height="200" class="img-thumbnail" height="" src="data:image;base64,{!! base64_encode($decryptMedicalCard) !!}" alt="" />

Now, where I'm stuck is that i need to do the same for files(pdf, txt,etc). They are encrypted when i use the method above but can't seem to see how can i view them using the same method for the image. I have tried changing the "data: " inside the src and changing the img tag to embed:

<embed width="300" height="200" class="img-thumbnail" src="data: ;base64,{!! base64_encode($decrypt2ndMedicalCard) !!}"/>

Can't get to make it work.

Thanks in advance