Creating default object from empty value

Posted 9 months ago by kgurleyen

Help me pleas. - I get such an error in my project.

Not!!: I get an error in updating. it just fails to update

Guess : salary_type

Editcontroller Upload class

public $data;
public $msg = [];
public $uri = [];

/**
 * EditController constructor.
 */
public function __construct()
{
    parent::__construct();

    // From Laravel 5.3.4 or above
    $this->middleware(function ($request, $next) {
        $this->commonQueries();

        return $next($request);
    });
}

/**
 * Common Queries
 */
public function commonQueries()
{
    // References
    $data = [];

    // Get Countries
    $data['countries'] = $this->countries = CountryLocalizationHelper::transAll(CountryLocalization::getCountries());
    $this->countries = $data['countries'];
    view()->share('countries', $data['countries']);

    // Get Categories
    $data['categories'] = Category::trans()->where('parent_id', 0)->with([
        'children' => function ($query) {
            $query->trans();
        },
    ])->orderBy('lft')->get();
    view()->share('categories', $data['categories']);
    
     // Günlük Aylık Yıllık Kiralama
       $data['salary_type'] = SalaryType::where('translation_lang', $this->lang->get('abbr'))->get();
        view()->share('salary_type', $data['salary_type']);

    // Get Post Types
    $data['postTypes'] = PostType::trans()->get();
    view()->share('postTypes', $data['postTypes']);

    // Count Packages
    $data['countPackages'] = Package::trans()->where('currency_code', config('country.currency'))->count();
    view()->share('countPackages', $data['countPackages']);

    // Count Payment Methods
    $data['countPaymentMethods'] = $this->countPaymentMethods;

    // Save common's data
    $this->data = $data;
}

/**
 * Show the form the create a new ad post.
 *
 * @param $postId
 * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
 */
public function getForm($postId)
{
    return $this->getUpdateForm($postId);
}

/**
 * Update ad post.
 *
 * @param $postId
 * @param PostRequest $request
 * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
 */
public function postForm($postId, PostRequest $request)
{
    $post->salary_type_id = $request->input('salary_type');
    return $this->postUpdateForm($postId, $request);
    
}

}

Edit.blade

@foreach ($salary_type as $type) <option value="{{ $type->tid }}" @if(old('salary_type', $post->salary_type_id)==$type->tid)selected="selected"@endif> {{ $type->name }} @endforeach

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.