Ignore:
Timestamp:
02/24/21 21:58:42 (4 years ago)
Author:
Berat Kjufliju <kufliju@…>
Branches:
master
Children:
ff9da8b
Parents:
0c07a90
Message:

ADD technoweek offer, companies

File:
1 edited

Legend:

Unmodified
Added
Removed
  • app/Http/Controllers/Blog/BlogController.php

    r0c07a90 rf457265  
    44
    55use App\Http\Requests\Blog\CommentRequest;
     6use App\Http\Requests\Blog\CompanyRequest;
    67use App\Http\Requests\Blog\PostLikeRequest;
    78use App\Http\Requests\Blog\PostUnlikeRequest;
     9use App\Models\Company;
    810use App\Models\Tag;
    911use App\Models\Like;
     
    1517use App\Http\Controllers\Controller;
    1618use App\Notifications\NewCommentAdded;
     19use Illuminate\Support\Facades\DB;
    1720
    1821class BlogController extends Controller
     
    226229        ]);
    227230    }
     231
     232    public function storeCompany(CompanyRequest $request)
     233    {
     234        DB::transaction(function () use ($request) {
     235
     236            $company = new Company();
     237            $company->name = $request->name;
     238            $company->website = $request->website;
     239            $company->email = $request->email;
     240
     241            $company->save();
     242
     243            if ($company->wasRecentlyCreated) {
     244                $this->disableOfferModal();
     245            }
     246        });
     247
     248        return redirect()->route("blog.index");
     249    }
     250
     251    public function disableOffer()
     252    {
     253        $this->disableOfferModal();
     254        return redirect()->route("blog.index");
     255    }
     256
     257    private function disableOfferModal()
     258    {
     259        if (!session()->has("offer_disabled")) {
     260            session()->push("offer_disabled", true);
     261        }
     262    }
    228263}
Note: See TracChangeset for help on using the changeset viewer.