119 *
120 * @return A collection of tickets that have a status_id of 3.
121 */
122 public function inProgress()123 {
124 $tickets = Ticket::where('status_id', 3)->paginate(10);
125 return view('ticket.index', compact('tickets'));
146 *
147 * @return An array of occurrences.
148 */
149 public function occurrences($id)150 {
151 $occurrences = \App\Models\Occurrences::where('ticket_id', $id)->get()->toArray();
152 return response()->json($occurrences);
108 *
109 * @return A collection of tickets that have a status_id of 2.
110 */
111 public function pending()112 {
113 $tickets = Ticket::where('status_id', 2)->paginate(10);
114 return view('ticket.index', compact('tickets'));
21 *
22 * @return The ticket that is associated with the comment.
23 */
24 public function ticket()25 {
26 return $this->belongsTo('App\Models\Ticket');
27 }
51 *
52 * @return The access level of the user.
53 */
54 public function accessLevel() 55 {
56 return $this->belongsTo('App\Models\AccessLevel');
57 }
The typehint provided for the function is not a valid class type. This may happen because of a typo, or the class specified in typehint is not present in the current namespace. You can also face this issue on using native union types if your PHP version is < 8.0. Native union types are only available in PHP 8.0 and later.
// invalid: User class used as return type doesn't exists
function getUser(): User
{
return new User('John');
}
class User
{
public function update(array $data) {}
}
// invalid: Parameter type contains typo
function updateUser(Usr $user, array $data): void
{
$user->update(['name' => $data['name']]);
}
Make sure class used in return typehint exists:
class User
{
private string $name;
public function __construct(string $name)
{
$this->name = $name;
}
}
function getUser(): User
{
return new User('John');
}
Make sure there are no typos:
class User
{
public function update(array $data) {}
}
// invalid: Parameter type contains typo
function updateUser(User $user, array $data): void
{
$user->update(['name' => $data['name']]);
}