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 month 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
1 month 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
2 months 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
5 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
5 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
5 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
6 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.