#need assistance with a laravel error

1 messages · Page 1 of 1 (latest)

solid igloo
#

this is the error in the laravel logs:

[stacktrace]```
#

let me send the file associated with the error

#

namespace App\Helpers;

use DB;
use App\Models\Notification;

class Notifications {

    /*
    |--------------------------------------------------------------------------
    | Notifications
    |--------------------------------------------------------------------------
    |
    | Creates user notifications.
    |
    */

    /**
     * Creates a new notification.
     *
     * @param  string                 $type
     * @param  \App\Models\User\User  $user
     * @param  array                  $data
     * @return bool
     */
    public function create($type, $user, $data)
    {
        DB::beginTransaction();

        try {
            $notification = Notification::create([
                'user_id'               => $user->id,
                'notification_type_id'  => Notification::getNotificationId($type),
                'data'                  => json_encode($data),
                'is_unread'             => 1
            ]);

            $user->notifications_unread++;
            $user->save();
            
            DB::commit();
            return true;
        } catch(\Exception $e) { 
            $this->setError('error', $e->getMessage());
        }
        DB::rollback();
        return false;
    }
}```
#

now ill send the db its using

#

namespace App\Http\Controllers\Admin\Users;

use Auth;
use Config;
use Illuminate\Http\Request;
use App\Models\User\User;
use App\Models\Item\Item;
use App\Models\Pet\Pet;
use App\Models\Recipe\Recipe;
use App\Models\Currency\Currency;
use App\Models\Claymore\Gear;
use App\Models\Claymore\Weapon;
use App\Models\User\UserItem;
use App\Models\Character\CharacterItem;
use App\Models\Trade;
use App\Models\Character\CharacterDesignUpdate;
use App\Models\Submission\Submission;
use App\Models\Character\Character;
use App\Services\CurrencyManager;
use App\Services\InventoryManager;
use App\Services\Stat\ExperienceManager;
use App\Services\PetManager;
use App\Services\Recipe\RecipeService;
use App\Http\Controllers\Controller;
use Illuminate\Database\Eloquent\Model;

/**
 * GrantController Class.
 *
 * @package App\Http\Controllers\Admin\Users
 */
class GrantController extends Controller
{
    // ... existing methods ...

    /**
     * Show the item search page.
     *
     * @return \Illuminate\Contracts\Support\Renderable
     */
    public function getItemSearch(Request $request)
    {
        $item = Item::find($request->only(['item_id']))->first();

        if ($item) {
            // Gather all instances of this item
            $userItems = UserItem::where('item_id', $item->id)->where('count', '>', 0)->get();
            $characterItems = CharacterItem::where('item_id', $item->id)->where('count', '>', 0)->get();

            // Gather the users and characters that own them
            $users = User::whereIn('id', $userItems->pluck('user_id')->toArray())->orderBy('name', 'ASC')->get();
            $characters = Character::whereIn('id', $characterItems->pluck('character_id')->toArray())->orderBy('slug', 'ASC')->get();

            // Gather hold locations
            $designUpdates = CharacterDesignUpdate::whereIn('user_id', $userItems->pluck('user_id')->toArray())->whereNotNull('data')->get();
            $trades = Trade::whereIn('sender_id', $userItems->pluck('user_id')->toArray())->orWhereIn('recipient_id', $userItems->pluck('user_id')->toArray())->get();
            $submissions = Submission::whereIn('user_id', $userItems->pluck('user_id')->toArray())->whereNotNull('data')->get();
        }

        return view('admin.grants.item_search', [
            'item' => $item ? $item : null,
            'items' => Item::orderBy('name')->pluck('name', 'id'),
            'userItems' => $item ? $userItems : null,
            'characterItems' => $item ? $characterItems : null,
            'users' => $item ? $users : null,
            'characters' => $item ? $characters : null,
            'designUpdates' => $item ? $designUpdates : null,
            'trades' => $item ? $trades : null,
            'submissions' => $item ? $submissions : null,
        ]);
    }
}

/**
 * Notification Model.
 *
 * @package App\Models
 */
class Notification extends Model
{
    // ... existing Notification class code ...
}

// Move this outside of the GrantController class
const GALLERY_SUBMISSION = 512;```