{"id":93577,"date":"2025-01-18T23:54:33","date_gmt":"2025-01-18T20:24:33","guid":{"rendered":"https:\/\/nabfollower.com\/blog\/vacancy-page-296l\/"},"modified":"2025-01-18T23:54:33","modified_gmt":"2025-01-18T20:24:33","slug":"vacancy-page-296l","status":"publish","type":"post","link":"https:\/\/nabfollower.com\/blog\/vacancy-page-296l\/","title":{"rendered":"\u0635\u0641\u062d\u0647 \u062c\u0627\u06cc \u062e\u0627\u0644\u06cc &#8211; \u0627\u0646\u062c\u0645\u0646 DEV"},"content":{"rendered":"<div data-article-id=\"2223063\" id=\"article-body\">\n<p>\u0633\u0644\u0627\u0645 \u0645\u0646 \u062f\u0631 \u0646\u0645\u0627\u06cc\u0634 \u062c\u0627\u06cc \u062e\u0627\u0644\u06cc \u062f\u0631 \u0635\u0641\u062d\u0647 \u0645\u0634\u06a9\u0644 \u062f\u0627\u0631\u0645<\/p>\n<p>\u0641\u0636\u0627\u06cc \u0646\u0627\u0645 App\\Http\\Controllers.<\/p>\n<p>\u0627\u0632 App\\Models \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f.<br \/>\u0627\u0632 App\\Models\\Category \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f.<br \/>\u0627\u0632 App\\Services\\VacancyService \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f.<br \/>\u0627\u0632 Illuminate\\Http\\Request \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f.<br \/>\u0627\u0632 Illuminate\\Validation\\Rule \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f.<br \/>\u0627\u0632 App\\Models\\Vacancy \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f.<br \/>\u0627\u0632 Illuminate\\Support\\Facades\\Gate \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f.<br \/>\u0627\u0632 Illuminate\\Validation\\Rules\\File \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f.<\/p>\n<p>\u0627\u0632 App\\Actions\\AddVacancyAction \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f.<br \/>\u0627\u0632 App\\Actions\\UpdateVacancyAction \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f.<\/p>\n<p>\u0627\u0632 App\\Actions\\DestroyVacancyAction \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f.<\/p>\n<p>\u0627\u0632 Illuminate\\Database\\Eloquent\\Model \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f.<br \/>\u0627\u0632 App\\Http\\Requests\\StoreVacancyRequest \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f.<\/p>\n<p>\u06a9\u0644\u0627\u0633 VacancyController \u06a9\u0646\u062a\u0631\u0644\u0631 \u0631\u0627 \u06af\u0633\u062a\u0631\u0634 \u0645\u06cc \u062f\u0647\u062f<br \/>{<br \/>\u0645\u062d\u0627\u0641\u0638\u062a \u0634\u062f\u0647 $\u062e\u062f\u0645\u0627\u062a;<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>\/\/ Other model methods and properties\n\n\n\n\n      \/\/tbc add CRUD action functions- see week 4 notes\n\/\/start by implmenting index action- see week 4 index action and view\npublic function index(Request $request)\n{\n    if (!Gate::allows('viewAny', Vacancy::class)) {\n    return redirect()-&gt;route('login')-&gt;with('info', 'Please Login to view vacancies');\n    }\n    $size = $request-&gt;input('size', 10);\n    $sort = $request-&gt;input('sort', 'id');\n    $direction = $request-&gt;input('direction', 'asc');\n    $search = $request-&gt;query('search', null);\n\n    \/\/ $vacancies = Vacancy::with(['category'])\n    \/\/     -&gt;search($search)\n    \/\/     -&gt;sortable($sort, $direction)\n    \/\/     -&gt;paginate($size)\n    \/\/     -&gt;withQueryString();\n\n    $vacancies = $this-&gt;service-&gt;findAll($search, $sort, $direction, $size);\n\n    return view('vacancies.index', ['vacancies' =&gt; $vacancies, 'search' =&gt; $search]);\n} _\n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div>\n<blockquote>\n<ul>\n<li>\/\/ \u0646\u0645\u0627\u06cc\u0634 \u0644\u06cc\u0633\u062a \u062c\u0627\u0647\u0627\u06cc \u062e\u0627\u0644\u06cc _ \u062a\u0627\u0628\u0639 \u0639\u0645\u0648\u0645\u06cc create() {<\/li>\n<\/ul>\n<\/blockquote>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>    if (!Gate::allows('create', Vacancy::class)) {\n        return redirect()-&gt;back()\n            -&gt;with('warning', 'Not authorised');\n    } else {\n\n        $vacancy = new Vacancy;\n\n        $categories = $this-&gt;service-&gt;getCategorySelectList();\n        return view('vacancies.create', ['vacancy' =&gt; $vacancy, 'categories' =&gt; $categories]);\n    } \/\/ show create vacancy form\n\n\n}\n\npublic function store(Request $request, Vacancy $service)\n{\n\n\n    Gate::allows('create', Vacancy::class);\n\n    $data = $request-&gt;validate([\n        'title' =&gt; ['required'],\n        'closing date' =&gt; ['required'],\n        'category_id' =&gt; ['required'],\n        'skills required' =&gt; ['required', 'numeric'],\n        'location' =&gt; ['required', 'numeric', 'min:0', 'max:5'],\n        'job description' =&gt; ['min:0', 'max:500'],\n        ['category_id' =&gt; 'The category field is required']\n    ]);\n\n    \/\/ store new vacancy\n    $vacancy = $service-&gt;create($data);\n    if(!$vacancy){\n        return redirect()-&gt;route('vacancies.index')-&gt;with('error', 'Failed to create vacancy');\n    }\n\n\n        return redirect()-&gt;route('vacancies.show', $vacancy-&gt;id)-&gt;with('success', 'Vacancy created successfully');\n    }\n\n\/\/ public function store(StoreVacancyRequest $request, AddVacancyAction $action)\n\n\n\n\n\n\npublic function show(int $id)\n{\n\n    if (!Gate::allows('viewAny', Vacancy::class)) {\n        return redirect()-&gt;route('login')-&gt;with('info', 'Please Login to view vacancies');\n    }\n    $vacancy = Vacancy::findOrFail($id);\n    return view('vacancies.show', ['vacancy' =&gt; $vacancy]);\n} \/\/ display specified vacancy\n\npublic function edit(int $id)\n{\n    if (!Gate::allows('update', Vacancy::class)) {\n        return redirect()-&gt;route('login')-&gt;with('info', 'Please Login to edit a vacancy');\n    }\n\n    $vacancy = Vacancy::findOrFail($id);\n     $categories = Category::all()-&gt;pluck('name', 'id');\n\n\n    return view('vacancies.edit', ['vacancy' =&gt; $vacancy, 'categories' =&gt; $categories]);\n}\npublic function update(int $id, array $data, Request $request) \n\n\n{\n  if  (!Gate::allows('update', Vacancy::class)) {\n    return redirect()-&gt;back()\n        -&gt;with('warning', 'Not authorised');\n  }\n\n    $data = $request-&gt;validate([\n        'title' =&gt; ['required', Rule::unique('vacancies')-&gt;ignore($id)],\n        'category_id' =&gt; ['required'],\n        'closing_date' =&gt; ['required'],\n        'skills_required' =&gt; ['required', 'numeric'],\n        'location' =&gt; ['required', 'numeric', 'min:0', 'max:5'],\n        'job_description' =&gt; ['min:0', 'max:500'],\n        'image' =&gt; ['nullable', File::types(['png', 'jpg', 'jpeg', 'webp'])-&gt;max(1024)],\n    ]);\n\n\n\n    $vacancy = $this-&gt;service-&gt;update($id, $data);\n    if ($vacancy === null) {\n        return redirect()-&gt;route('vacancies.index')\n            -&gt;with('error', 'Vacancy not found');\n    }\n    return redirect()-&gt;route(\"vacancies.show\", $id)\n        -&gt;with('success', 'Vacancy updated successfully');\n}\n\n\/\/ Other methods like destroy, create, etc.\n\n\npublic function delete(int $id)\n{\n    \/\/ authorise the deletion\n    Gate::authorize('delete', Vacancy::class);\n\n\n    if ($this-&gt;service-&gt;delete($id)) {\n        return redirect()-&gt;route('vacancies.index')-&gt;with('success', 'Vacancy deleted successfully');\n    } else {\n        return redirect()-&gt;route('vacancies.index')-&gt;with('error', 'Vacancy not found');\n}\n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p>}<\/p>\n<p>}<br \/>\/\/ \u0646\u0634\u0627\u0646 \u062f\u0627\u062f\u0646 \u0648\u06cc\u0631\u0627\u06cc\u0634 \u0641\u0631\u0645 \u062c\u0627\u06cc \u062e\u0627\u0644\u06cc <br \/>\/\/ \u0628\u0647\u200c\u0631\u0648\u0632\u0631\u0633\u0627\u0646\u06cc \u0639\u0645\u0644\u06a9\u0631\u062f \u0639\u0645\u0648\u0645\u06cc (\u062f\u0631\u062e\u0648\u0627\u0633\u062a \u062f\u0631\u062e\u0648\u0627\u0633\u062a $\u060c \u0631\u0634\u062a\u0647 $id) { \u2026 ;} \/\/ \u0628\u0647\u200c\u0631\u0648\u0632\u0631\u0633\u0627\u0646\u06cc  <\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>\/\/public function destroy(int $id) { \u2026 ;} \/\/ remove specified vacancy\n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u0633\u0644\u0627\u0645 \u0645\u0646 \u062f\u0631 \u0646\u0645\u0627\u06cc\u0634 \u062c\u0627\u06cc \u062e\u0627\u0644\u06cc \u062f\u0631 \u0635\u0641\u062d\u0647 \u0645\u0634\u06a9\u0644 \u062f\u0627\u0631\u0645 \u0641\u0636\u0627\u06cc \u0646\u0627\u0645 App\\Http\\Controllers. \u0627\u0632 App\\Models \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f.\u0627\u0632 App\\Models\\Category \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f.\u0627\u0632 App\\Services\\VacancyService \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f.\u0627\u0632 Illuminate\\Http\\Request \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f.\u0627\u0632 Illuminate\\Validation\\Rule \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f.\u0627\u0632 App\\Models\\Vacancy \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f.\u0627\u0632 Illuminate\\Support\\Facades\\Gate \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f.\u0627\u0632 Illuminate\\Validation\\Rules\\File \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f. \u0627\u0632 App\\Actions\\AddVacancyAction \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f.\u0627\u0632 App\\Actions\\UpdateVacancyAction \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f. \u0627\u0632 App\\Actions\\DestroyVacancyAction \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f. \u0627\u0632 Illuminate\\Database\\Eloquent\\Model \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f.\u0627\u0632 App\\Http\\Requests\\StoreVacancyRequest \u0627\u0633\u062a\u0641\u0627\u062f\u0647 &hellip;<\/p>\n","protected":false},"author":2,"featured_media":93578,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"","fifu_image_alt":"","footnotes":""},"categories":[339],"tags":[],"class_list":["post-93577","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dev"],"_links":{"self":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts\/93577","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/comments?post=93577"}],"version-history":[{"count":0,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts\/93577\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/media\/93578"}],"wp:attachment":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/media?parent=93577"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/categories?post=93577"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/tags?post=93577"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}