screwtape_mk

screwtape_mk

Member Since 1 Year Ago

Experience Points 2,160
Experience Level 1

2,840 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 0
Lessons
Completed
Best Reply Awards 0
Best Reply
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.

16 May
1 week ago

screwtape_mk started a new conversation Ajax And Laravel Autocomplete Slow

I have a form with automplete feature as you type. The feature is slow. An average typing speed is faster than the autocomplete list. You can finish typing before the suggestion pops out. it uses jquery to and makes an ajax call to a URL which calls a function within a controller that then runs all the list containing the typed string:

 public function searchResponse(Request $request){
        $query1 = $request->get('term','');
        $c1=\DB::table('T_EMPLOYEE_SERVICE_AREAS');
        if($request->type=='EmpService')
        
            {
                $c1->where('EmployeeService','LIKE','%'.$query1.'%')
                            ->groupBy('EmployeeService')
                            ->get();
            }
      
           $c1=$c1->get();        
        $data=array();
        foreach ($c1 as $service) {
                $data[]=array('EmployeeService'=>$service->EmployeeService);
        }
        if(count($data))
             return $data;
        else
            return ['EmployeeService'=>''];
    }
    

Aside from maybe optimizing the above query - how would i go about checking where the the most time is spent. The network tab in the chrome developer tools only showed me how long the url that gets called took and its about 700ms.

I have added a link of the exact same autocomplete script i got from another forum

http://www.expertphp.in/article/laravel-5-autocomplete-mutiple-fields-using-jquery-ajax-and-mysql

22 Apr
1 month ago

screwtape_mk left a reply on Unexpected Else

Thank you very helpful

screwtape_mk left a reply on Unexpected Else

@DALMA - any documentation link on this?

because now i have :

@if 
    @if 
        @if 

without an @else condition. Would i need to make it

@if 
    @if 
        @if 

        @endif 

    @endif 

@endif

``
?
20 Apr
1 month ago

screwtape_mk left a reply on Trying To Get Property Of Non-object

@ASHRAAM - It turns out that it wasnt $bookingPayments that was causing issues but another variable and have fixed it thanks

18 Apr
1 month ago

screwtape_mk left a reply on Trying To Get Property Of Non-object

@SERGIU17 - ``` dd($bookingPayments);

I had already done and is shown in the question i posted

Collection {#199 ▼ #items: array:2 [▼ 0 => UserPayments {#202 ▶} 1 => UserPayments {#203 ▶} ] }

Then

dd($bookingPayments->first());

Gives the first item: 

0 => UserPayments {#202 ▶}

Then

dd($bookingPayments->first()->employee_id);


outputs the employee_id I am looking for. I am assuming that all these dd are to be done within the controller 'cause thats the only i know how.

The problem seems to be when the same gets applied in the view:

$Employee->id==$bookingPayments->first()->employee_id

screwtape_mk started a new conversation Trying To Get Property Of Non-object

I have a collection

$bookingPayments

can be seen here

Collection {#199 ▼
  #items: array:2 [▼
    0 => UserPayments {#202 ▶}
    1 => UserPayments {#203 ▶}
  ]
}

It gets passed on to a view; which returns an error in the following expression in the view:

$bookingPayments->first()->employee_id

Not sure what could be the problem

16 Apr
1 month ago

screwtape_mk left a reply on Unexpected Else

doesnt an @elseif qualify as a 4th if

screwtape_mk started a new conversation Unexpected Else

I apparently have an unexpected else in line 58 (The last 'else' below). I have been on this for almost an hour and i cant seem to see why

            @if(Auth::check())
                
                    
                    @if($bookingRequests->count()>0 || $bookingPayments->count()>0 )
                    
                            @if($Employee->id==$bookingPayments->first()->employee_id)
                                
                                //do something
                    
                            @elseif($Employee->id==$bookingRequests->first()->employee_id)
                                            //do something
                                @else
                                            //do something
                            @endif
                                    
                            @endif
                        
                    @else
                                
                                    //do something
                    @endif
                
                    
                
                
            @else
                                    //do something
            @endif
                    
03 Apr
1 month ago

screwtape_mk left a reply on Placing Modal Form To A List Of Items And Returning Data Of The Items

It finally worked, you basically need to modify the JQUERY that handles the modal and capture the data as the modal is fired pass that data over to whatever 'id' whose content you can then request through the norma $request->input process of laravel

I cant believe a mere modal set me off on a different tanget all together - a whole 2 weeks lost

02 Apr
1 month ago

screwtape_mk left a reply on Placing Modal Form To A List Of Items And Returning Data Of The Items

ive looked up a few helpful tutorials - definitely not as intuitive as i had imagined...

screwtape_mk left a reply on Placing Modal Form To A List Of Items And Returning Data Of The Items

@FTIERSCH - This is definitely the answer im looking for - except i need you detailed explanation as to how i would do this - im new to javascripts/bootstrap and laravel

screwtape_mk left a reply on Placing Modal Form To A List Of Items And Returning Data Of The Items

Please assist as to how would i do 1 - i definitely dont want multiple modals

31 Mar
1 month ago

screwtape_mk left a reply on Using A Variable In One Function To Another In The Same Controller

not sure if this is clear -

getBookingItem($empl_id) 

uses that variable independant of

postBookings(Request $request)

....BUT after evaluating getBookingItem($empl_id) its value must be called in

postBookings

screwtape_mk left a reply on Using A Variable In One Function To Another In The Same Controller

The variable

$BookedEmployee

is a number and i just want that value/number - some background on it:

$empl_id

comes from a route in some view:

<a href="{{route('user.BookingItem',['empl_id'=>$Employee->id])}}" class="btn btn-primary">Book Me</a>

that value is passed to:


public function getBookingItem($empl_id){
    
        
        $BookedEmployee=Employee::where('id',$empl_id)
                    ->first();
        
    }

and evaluate to just ONE number and i wanted to grab that number and use it in :

public function postBookings(Request $request){


//use it here 

dd($BookedEmployee);

}

screwtape_mk left a reply on Using A Variable In One Function To Another In The Same Controller

Let me rather put it this way -


return Employee::where('id',$empl_id)
        ->first();

Only has one value that is the out-put of the passed $empl_id from another source and im happy with that -

Now the content of


return Employee::where('id',$empl_id)
        ->first();

is what i want passed to the 2nd function

screwtape_mk left a reply on Using A Variable In One Function To Another In The Same Controller

@CRONIX - can i just assume that

$empl_id

will be passed also to :

postBookings

screwtape_mk started a new conversation Using A Variable In One Function To Another In The Same Controller

I have a variable in one function which I intend to use in the next function:

Function 1:


public function getBookingItem($empl_id){
    
        
        $BookedEmployee=Employee::where('id',$empl_id)
                    ->first();
        
    }

Function 2:

public function postBookings(Request $request){


//use it here 

dd($BookedEmployee);

}

screwtape_mk left a reply on Passing Variable From One Function To Another Function In Same Controller

@PHPMICK - But what if

$variable

is defined within 'anotherFunction' like below:

public function anotherFunction($variable){
   $variable = "this is pretty basic stuff in any language";
}

But must be used within 'oneFunction'

screwtape_mk left a reply on Why Do I Only Return The First Item Of A Collection

Ok i have atleast figured that the problem the modal. The right relevant employee data of the worker i intend to book does get passed to the route:

{{route('user.BookingItem',['empl_id'=>$Employee->id])}}

The problem is i now need to figure how to pass the same data to the modal

screwtape_mk started a new conversation Why Do I Only Return The First Item Of A Collection

Why do I only get the first item of this collection and not the one im looking for

I have search controller that returns data to a results view:

SearchController:


class SearchController extends Controller {
        $Employees=Employee::where(DB::raw('EmployeeService'),'LIKE',"%{$query1}%")
                    ->where('AccentCity','LIKE',"%{$query2}%")
                    ->get();
        
        
        Session::put('EmployeeData',$Employees);
        return view('search.results')
                        ->with('Employees',$Employees)

}

Results view:

@if(!$Employees->count())
    <p>No results found</p>
@else


<div class="panel panel-default">
            <div class="panel-heading"><h3></h3></div>
                <div class="panel-body">
                    <div class="row">
                        <div class="col-lg-12">
    
    
                                @foreach($Employees as $Employee)
                                        
                                        @include('user/partials/employeeblock')
                                @endforeach
    
    
        
                        </div>
                    </div>
                </div>
            </div>
</div>
@endif

user/partials/employeeblock: (This is where the problem is where $Employee->id only returns the first item of what instead of the one im interested in)

    <div class="row no-gutters mb-5 mb-lg-0" style="padding:10px">
            
            
            @include('templates.partials.bookingform') 
            
            
                @if(Auth::check())
                
                    
                    @if($bookingRequests->count()>0)
                    
                            @if($Employee->id==$bookingRequests->first()->employee_id)
                                    <a href="#" class="btn btn-primary" data-toggle="modal" data-target="#bookingModal">Show Number</a>
                                @else
                
                                    <a href="{{route('user.BookingItem',['empl_id'=>$Employee->id])}}" class="btn btn-primary" data-toggle="modal" data-target="#bookingModal">Book Me</a>
                        
                            @endif
                        
                        @else
                                
                                    <a href="{{route('user.BookingItem',['empl_id'=>$Employee->id])}}" class="btn btn-primary" data-toggle="modal" data-target="#bookingModal">Book Me</a>
                    @endif
                
                @else
                                    <a href="{{route('search.searchItem',['serv'=>$Employee->EmployeeService,
                                                                    'suburb'=>$Employee->AccentCity]
                                                                    )}}" class="btn btn-primary" >Book Me</a>
                @endif
                    
                    
                    
                
                </div>
             </div>
30 Mar
1 month ago

screwtape_mk started a new conversation Placing Modal Form To A List Of Items And Returning Data Of The Items

I have a script that gives search results of workers and each of the workers have a ‘book me’ button next to them.

The form you fill when you click the ‘book me’ button is (rendered as a modal):

    
    <form class="form-inline " role="form" method="POST" action="{{route('user.employeebooking',['empl_id'=>$Employee->id])}}">
                
                    <!-- <input type="hidden" name="_token" value="{{ csrf_token() }}"> -->
                    <label for="comment">Comment(Optional):</label>
                    
                    <textarea class="form-control form-inline" name="comment" 
                    value="{{Request::old('comment')?:''}}"rows="3" style="width:100%"></textarea>
                    
                    <button type="submit" class="btn btn-primary">Submit</button>
                    
                    <input type="hidden" name="_token" value="{{Session::token()}}">
                        
                </form>

The problem is that $Employee->id contains the value of the first worker in the result set not the specific one I wish to book.

Route:

Route::post('/employeebooking/{empl_id}',[
            'uses'=>'\App\Http\Controllers\[email protected]',
            'as'=>'user.employeebooking',
            'middleware'=>['auth'],

Method:

public function postBookings(Request $request,$employeeid)
        {
            dd($employeeid);

}

screwtape_mk left a reply on Looping Multiping Collections At The Same Time

Ok what ended up working is to apply an if condition within the for loop to check if something like:

$Employee->id==$bookingRequests->first()->employee_id

screwtape_mk started a new conversation Looping Multiping Collections At The Same Time

I have seen this question asked a few times and in each case its not clear what the solution is.

I need to loop through 2 collections one contains employees info the other contains bookings of these employees

If something like this were possible

@foreach($Employees as $Employee, $bookings as $booking)
        // return something
@endforeach

Im reluctant to use a nested for loop if a nested for loop will mean the operation will first loop through the inner loop till done and repeats each time the outer loop increments

27 Mar
1 month ago

screwtape_mk left a reply on Multiple Tables On A Model / Relationships, Whatever Is Allowed

Thought there was another way but yeah relationships not necessary THANKS

26 Mar
1 month ago

screwtape_mk started a new conversation Multiple Tables On A Model / Relationships, Whatever Is Allowed

I have a Bookings model

Bookings.php

with

protected $table  = 'V_BOOKINGS'

'V_BOOKINGS' is a mysql view that contains user’s booking data with other info from other tables in it.

I have another table that also contains user bookings :

user_bookings 

it is part of the view above but not with enriched data as the V_BOOKINGS view

I have a BookingsController that is supposed to add data into user_bookings, except it only attempts to insert into the view above, which is fine - I wasn’t expecting it to.

What I want to do is to insert the data in the controller to : user_bookings. Except I have now learned my model can only have 1 table.

I apparently have to create a relationship between the view and the table. Well theres no real logical relationship except to say theres one-to-one relationship between the 2 ‘booking’ models..

If i'm on the right track on creating these relationships , do let me know and if you won’t mind show by way of a code snippet how this would be done

19 Mar
2 months ago

screwtape_mk left a reply on Auth Middleware On A Button

so you mean the button should call a route - which will be the form modal - if not authenticated then it will redirect to the login page but if authenticated the modal will pop up - is that what you saying

screwtape_mk started a new conversation Auth Middleware On A Button

I have a button when pressed pop out a form modal. I have 2 things i need to do:

  1. Apply Auth Middleware on the button so that clicking the button redirects to the sign in page

  2. Save the URL before Authentication so that you store return it after loggin in.

I have an idea on how to do '2'.

'1' is what i need the most help in

14 Mar
2 months ago

screwtape_mk left a reply on Auth Middleware Reroutes To A Wrong Signin Page Auth.signin

Ok i solved it by going to the /Http/Middleware/Authenticate.php and changed this part of the code:

                  return redirect()->guest('auth.signin'); 

To:

                  return redirect()->guest('signin');

screwtape_mk started a new conversation Auth Middleware Reroutes To A Wrong Signin Page Auth.signin

I am using laravel 5.1 and i have applied an Auth middleware to a route, it works except my auth page is: /signin Not what it reroutes to /Auth.signin

12 Mar
2 months ago

screwtape_mk started a new conversation Accessing Array Element: Undefined Index

i dont understand why i get this error:

Undefined index: phone

while

$EmployeeArr=json_decode($Employees);
dd($EmployeeArr);

gives:

array:1 [▼
  0 => {#171 ▼
    +"id": "37"
    +"phone": "0828988008"
    +"EmployeeName": "Ownway Kanju"
    +"EmployeeService": "Photographer"
    +"suburb": "Broadacres AH"
    +"AccentCity": "Four Ways"
    +"distance": "3.2891828545855133"
    +"tasks": "0"
  }
]

yet when i run:

dd($EmployeeArr['phone']);

i get the error above

screwtape_mk left a reply on Argument 1 Passed To App\Models\User::BookingRequest() Must Be An Instance Of App\Models\userBookings, None Given, Called In ../laravel/app/Http/Controllers/SearchController.php On Line 41 And Defined

I have an Employee model:

    public function getEmployeeMobile()
    
        {
            if ($this->phone){
            
            return "{$this->phone}";
            }
            
            return null;
        
        }
    
    ```

screwtape_mk left a reply on Argument 1 Passed To App\Models\User::BookingRequest() Must Be An Instance Of App\Models\userBookings, None Given, Called In ../laravel/app/Http/Controllers/SearchController.php On Line 41 And Defined

Ok i have tried to approach this in a different way. The ultimate goal is to have a particular button showing 'number ' if a searched employee has been booked already by the Authenticated user Or show ''Book Me" if that employee has not been booked.

I have altered BookingRequest to:

    public function BookingRequest($EmployeeNumber)
    
    {
    
        return $this->bookings()->where('booking_status','=','confirmed')
                                ->OrWhere('Employee_Phone','=',$EmployeeNumber)
                                ->get();

    }

I now get this error

Call to undefined method Illuminate\Database\Eloquent\Collection::getEmployeeMobile()

when i :

dd($Employees->getEmployeeMobile());

in the SearchController:

<?php 
namespace App\Http\Controllers;

use DB;
use Auth;
use App\Models\Employee;
use App\Models\User;
use App\Models\Bookings;

use Illuminate\Http\Request;

use GuzzleHttp\Client;
use Session;



class SearchController extends Controller {

    public function getResults(Request $request)
    {
    
        $query1=implode("",$request->input('EmpService'));
        $query2=implode("",$request->input('AccCity'));
        
        
        $token=$request->input('g-recaptcha-response');
        
        
        if(!$query1){
            return redirect()->route('home');
        }
        
        $Employees=Employee::where(DB::raw('EmployeeService'),'LIKE',"%{$query1}%")
                    ->where('AccentCity','LIKE',"%{$query2}%")
                    ->get();
        
        
        dd($Employees->getEmployeeMobile());
11 Mar
2 months ago

screwtape_mk left a reply on Argument 1 Passed To App\Models\User::BookingRequest() Must Be An Instance Of App\Models\userBookings, None Given, Called In ../laravel/app/Http/Controllers/SearchController.php On Line 41 And Defined

its possible that the tutorial which has the the same

$bookingRequests=Auth::user()->BookingRequest() 

is a little simpler for the specific case im trying build for. in the tutorial the BookingRequest is defined within the user.php model as:


    public function BookingRequest(User $user)
    
    {
        return (bool)$this->bookings()->where('email',$user->email)
                                ->count();
                                
    }

screwtape_mk started a new conversation Argument 1 Passed To App\Models\User::BookingRequest() Must Be An Instance Of App\Models\userBookings, None Given, Called In ../laravel/app/Http/Controllers/SearchController.php On Line 41 And Defined

line 41 in searchController:

$bookingRequests=Auth::user()->BookingRequest();

User.php (Model):


    public function bookings() {
        
            return $this->hasMany('App\Models\Bookings');
    
    }   


    public function BookingRequest(userBookings $userBookings)
    
    {
        return (bool)$this->bookings()->where('email',$userBookings->email)
                                ->count();
                                
                                
                                
    
    }

The view:

@if(Auth::user()->BookingRequest($Userbookings))
                        <a href="#" class="btn btn-primary" data-toggle="modal" data-        
                            target="#bookingModal">Show Number</a>
@else
                
                        <a href="#" class="btn btn-primary" data-toggle="modal" data- 
                           target="#bookingModal">Book Me</a>
                        
@endif

Hope this is enough detail
10 Mar
2 months ago

screwtape_mk left a reply on Call To A Member Function Get() On Null

thanks so much super helpful!...cant believe i left out 'return'

09 Mar
2 months ago

screwtape_mk started a new conversation Call To A Member Function Get() On Null

I am trying to have a button of an employee show the text “Already booked” if the variable

count($bookingRequests)

returns something and if nothing then show “Book Me"

I have the following models and their relationships:

User.php and Bookings.php

User:

public function bookings() {
        
            return $this->hasMany('App\Models\Bookings');
    
    }   


    public function BookingRequest()
    
    {
        $this->bookings()->where('booking_status','=','confirmed')->get();  
    
    
    }


Bookings:

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

The view mentioned above is Employeeblock.blade.php:

    <div class="row no-gutters mb-5 mb-lg-0" style="padding:10px">
                
                    @if(count($bookingRequests))
                        <a href="#" class="btn btn-primary" data-toggle="modal" data-    
                                        target=“#bookingModal">Already Booked</a>
                    @else
                
                        <a href="#" class="btn btn-primary" data-toggle="modal" data- 
                                        target="#bookingModal">Book Me</a>
                        
                    @endif
                
         </div>

Which has data passed onto it by a controller SearchController:

In the following way:

<?php 
namespace App\Http\Controllers;

use DB;
use Auth;
use App\Models\Employee;
use App\Models\User;
use App\Models\Bookings;

use Illuminate\Http\Request;

use GuzzleHttp\Client;
use Session;

.
.
.
$bookingRequests=Auth::user()->BookingRequest()->get();

    return view(‘search.results’)->with('bookingRequests',$bookingRequests);

results.blade.php above has the following html:

<div class="panel panel-default">
            <div class="panel-heading"><h3></h3></div>
                <div class="panel-body">
                    <div class="row">
                        <div class="col-lg-12">
    
    
                                @foreach($Employees as $Employee)
                                        @include('user/partials/employeeblock')
                                @endforeach
    
    
        
                        </div>
                    </div>
                </div>
            </div>
</div>

06 Mar
2 months ago

screwtape_mk started a new conversation GuzzleHttp Undefined Offset: 1

Hi Guys

I am trying to integrate to a payment gateway and send sms'es from my application using GuzzleHttp:

i get the error in the tile and suspect is how i am passing the authentication as required by the API

Authentication requirement:

When using an API token, the value to be encoded will be <token-id>:<token-secret>. These values before Base64 encoding look something like this

BBDE1B476E03498AA768F66A286AABDC-01-B:9jSbVDK20!MXdfRGiIIFu#ffUE8*S

My API call:

        public function initiateSmsGuzzle($employeeMobile, $message)
                {
                  $client=new Client([
                    'headers'=>['content-type'=>'application/json','Accept'=>'application/json'],
                    ]);
                    
                    $ID=base64_encode('******_ID');
                    $KEY=base64_encode('******_KEY');

                     $response = $client->request('POST','https://api.bulksms.com/v1', [
                        'auth'=>[$ID.':'.$KEY],
                        'form_params' => [
                        
                        'message' => $message,
                        
                        'mobiles' => $employeeMobile,
                        ],
                ]);


        $response = json_decode($response->getBody(), true);
    }
    

The error above refers to this part of the Guzzle file:

laravel/vendor/guzzlehttp/guzzle/src/Client.php line 354

and that part contains this:

      if (!empty($options['auth']) && is_array($options['auth'])) {
            $value = $options['auth'];
            $type = isset($value[2]) ? strtolower($value[2]) : 'basic';
            switch ($type) {
                case 'basic':
                    // Ensure that we don't have the header in different case and set the new value.
                    $modify['set_headers'] = Psr7\_caseless_remove(['Authorization'], $modify['set_headers']);
                    $modify['set_headers']['Authorization'] = 'Basic '
                        . base64_encode("$value[0]:$value[1]");  //THIS IS LINE 354
                    break;
                case 'digest':
                    // @todo: Do not rely on curl
                    $options['curl'][CURLOPT_HTTPAUTH] = CURLAUTH_DIGEST;
                    $options['curl'][CURLOPT_USERPWD] = "$value[0]:$value[1]";
                    break;
                case 'ntlm':
                    $options['curl'][CURLOPT_HTTPAUTH] = CURLAUTH_NTLM;
                    $options['curl'][CURLOPT_USERPWD] = "$value[0]:$value[1]";
                    break;
            }
        }

screwtape_mk left a reply on Updated Models And Cache

I guess not and everything ran fine with the updated tables - thanks

screwtape_mk started a new conversation Updated Models And Cache

I have just updated some tables and views that are read by some of my Models. Please remind me if theres any cache that needs refreshing after doing so ?

05 Mar
2 months ago

screwtape_mk left a reply on Non-static Method App\Models\Employee::getEmployeeName() Should Not Be Called Statically, Assuming $this From Incompatible Context

No the id of the employee is not in the Request - subsequent methods in this controller use the request data, which i didnt include in this case

screwtape_mk started a new conversation Non-static Method App\Models\Employee::getEmployeeName() Should Not Be Called Statically, Assuming $this From Incompatible Context

I need to use a Model function in a controller but get the above error.

My Model:

<?php namespace App\Models;


use Illuminate\Database\Eloquent\Model;



class Employee extends Model 
{


    
    protected $table = ‘BLABLA’;
    

        public function getEmployeeName()
        
            {
                if ($this->EmployeeName){
            
                    return "{$this->EmployeeName}";
                    }
            
            return null;
        
            }
    
}

My controller:

<?php namespace App\Http\Controllers;


use Auth;

use DB;

use App\Models\Bookings;

use App\Models\User;

use App\Models\Employee;

use Illuminate\Http\Request;

class BookingsController extends Controller {

    public function postBooking(Request $request){

    $employee=Employee::getEmployeeName()->get();

    dd($employee);

}
    
    
    
}

screwtape_mk left a reply on Call To A Member Function GetName() On Null

@SNAPEY - A result of copying and pasting other applications but yeah was not necessary

04 Mar
2 months ago

screwtape_mk left a reply on Call To A Member Function GetName() On Null

well this is akward! I had no authenticated user...works now ! Thanks

screwtape_mk started a new conversation Call To A Member Function GetName() On Null

Hey Guys

I want to store the name of currently authenticated user into a variable $booker..but when i dd($booker) I get the error abover:

I have my User model as:


<?php namespace App\Models;

use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;

use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;


class User extends Model implements AuthenticatableContract
{
use Authenticatable;

public function getName()
    
        {
            if ($this->name){
            
            return "{$this->name}";
            }
            
            return null;
        
        }
}

I have a controller called BookingsController:

<?php namespace App\Http\Controllers;


use Auth;

use DB;

use App\Models\Bookings;

use App\Models\User;

use Illuminate\Http\Request;

class BookingsController extends Controller {

public function postBooking(Request $request){


            
            $booker=Auth::User()->getName();
            dd($booker);
}

}

Its at that controller that i encounter that error

02 Mar
2 months ago

screwtape_mk left a reply on Send Notif Via WhatsApp

any success?

screwtape_mk left a reply on Send Whatsapp In Laravel App

Did you ever come right with this- i am also looking to send messages to user's whatsapp from my laravel application

01 Mar
2 months ago

screwtape_mk left a reply on Send Message From Laravel To Whatsapp

Thanks will check it out. Has anyone done whats suggested here successfully?

https://www.youtube.com/watch?v=F5gxk5xhEgo