Skip to content

Commit

Permalink
Merge pull request #69 from Sanium/L-69
Browse files Browse the repository at this point in the history
L-69 Szybkie aplikowanie
  • Loading branch information
baloo1379 authored May 18, 2020
2 parents aa79ff6 + 0fde78a commit 1402ce4
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 8 deletions.
19 changes: 15 additions & 4 deletions app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Routing\Redirector;

class HomeController extends Controller
Expand All @@ -28,14 +29,24 @@ public function __construct()
/**
* Show the home page.
*
* @return Renderable
* @return Renderable|RedirectResponse|Redirector|Response
*/
public function welcome(): Renderable
public function welcome()
{
return view('welcome');
/** @var User $user */
$user = auth()->user();
if (null === $user) {
return view('welcome', [
'showForm' => true,
]);
}

return view('welcome', [
'showForm' => !$user->isClient(),
]);
}

/**
/**
* Show the application dashboard.
*
* @return Renderable|RedirectResponse|Redirector
Expand Down
10 changes: 7 additions & 3 deletions app/Http/Controllers/JobOfferResponseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ public function store(Request $request, Offer $offer)
$query->where('user_id', $user_id)->where('offer_id', $offer_id);
})->limit(1)->get();
if ($jor->isNotEmpty()) {
$request->session()->flash('status', __('You already respond to this offer..'));
return back();
$request->session()->flash('status', __('You already respond to this offer.'));
return $request->wantsJson()
? new Response(['error' => __('You already respond to this offer.')], 200)
: back();
}
$jor = $offer->jobOfferResponses()->create([
'user_id' => $user->id,
Expand All @@ -62,7 +64,9 @@ public function store(Request $request, Offer $offer)
}
Mail::to($jor->offer->user)->queue(new JobOfferResponseMail($jor->name, $jor->email, $jor->links, $jor->getFile()));
$request->session()->flash('status', __('Mail has been send.'));
return back();
return $request->wantsJson()
? new Response(['ok' => __('Mail has been send.')], 200)
: back();
}

/**
Expand Down
4 changes: 3 additions & 1 deletion resources/lang/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,14 @@
"Offer :name will expire on :date.": "Oferta :name wygaśnie :date.",
"You have been successfully verified.": "Zostałeś pomyślnie zweryfikowany.",
"Hello :name, you has been successfully registered.": "Witaj :name, zostałeś pomyślnie zarejestrowany.",
"You already respond to this offer.": "Juz odpowiedziałeś na tę ofertę.",
"Applications": "Zgłoszenia",
"Date": "Data",
"Download": "Pobierz",
"User verified": "Użytkownik zweryfikowany",
"Number of application": "Liczba zgłoszeń",
"Your applications": "Twoje zgłoszenia",
"You have canceled your application for position :name.": "Anulowałeś swoją aplikację na stanowisko :name.",
"Registration failed. Contact the administrator.": "Rejestracja nie udała się. Skontaktuj się z administratorem."
"Registration failed. Contact the administrator.": "Rejestracja nie udała się. Skontaktuj się z administratorem.",
"The given data was invalid.": "Podane dane były nieprawidłowe."
}
1 change: 1 addition & 0 deletions resources/lang/pl/validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
'rule-name' => 'custom-message',
],
],
'The given data was invalid.' => 'Podane dane były nieprawidłowe.',

/*
|--------------------------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions resources/views/welcome.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@

<!-- Scripts -->
@yield('javascript')
<script>
window.showForm = {{ $showForm ? 'true' : 'false' }};
</script>

</head>
<body>
Expand Down

0 comments on commit 1402ce4

Please sign in to comment.