Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelogic committed Jan 22, 2019
0 parents commit a412039
Show file tree
Hide file tree
Showing 190 changed files with 122,443 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_size = 2
39 changes: 39 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
/database
/.idea
/.git-bit
/.vscode
/.vagrant
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
.env
.phpunit.result.cache
20 changes: 20 additions & 0 deletions app/Category.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Category extends Model
{
protected $guarded = [];

public function jobs()
{
return $this->hasMany('App\Job');
}

public function getRouteKeyName()
{
return 'slug';
}
}
20 changes: 20 additions & 0 deletions app/City.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class City extends Model
{
protected $guarded = [];

public function jobs()
{
return $this->hasMany('App\Job');
}

public function getRouteKeyName()
{
return 'slug';
}
}
20 changes: 20 additions & 0 deletions app/Company.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Company extends Model
{
protected $guarded = [];

public function jobs()
{
return $this->hasMany('App\Job');
}

public function getRouteKeyName()
{
return 'slug';
}
}
42 changes: 42 additions & 0 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
];

/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')
// ->hourly();
}

/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');

require base_path('routes/console.php');
}
}
10 changes: 10 additions & 0 deletions app/Customer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Customer extends Model
{
protected $guarded = [];
}
51 changes: 51 additions & 0 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace App\Exceptions;

use Exception;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;

class Handler extends ExceptionHandler
{
/**
* A list of the exception types that are not reported.
*
* @var array
*/
protected $dontReport = [
//
];

/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array
*/
protected $dontFlash = [
'password',
'password_confirmation',
];

/**
* Report or log an exception.
*
* @param \Exception $exception
* @return void
*/
public function report(Exception $exception)
{
parent::report($exception);
}

/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $exception)
{
return parent::render($request, $exception);
}
}
42 changes: 42 additions & 0 deletions app/Helpers/DataFormat.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace App\Helpers;

class DataFormat {

public static function company($request)
{
$name = $request->company['name'];
$company = [
'city_id' => $request->company['city_id'],
'name' => $name,
'email' => $request->company['email'],
'about' => isset($request->company['about']) ? $request->company['about'] : '',
'slug' => str_slug($name)
];

return $company;
}

public static function job($request, $company_id)
{
$job_title = $request->job['title'];
return [
'category_id' => $request->job['category_id'],
'city_id' => $request->job['city_id'],
'company_id' => $company_id,
'job_type_id' => $request->job['job_type_id'],
'source_id' => array_key_exists('source', $request->job) ? $request->job['source']:0,
'title' => $job_title,
'location' => $request->job['location'],
'description' => isset($request->job['description']) ? $request->job['description'] : '',
'qualifications' => isset($request->job['qualifications']) ? $request->job['qualifications'] : '',
'responsibilities' => isset($request->job['responsibilities']) ? $request->job['responsibilities'] : '',
'howtoapply' => !isset($request->job['howtoapply']) ?: $request->job['howtoapply'],
'sitetoapply' => array_key_exists('sitetoapply', $request->job) ? $request->job['sitetoapply'] : '',
'slug' => str_slug($job_title . '-' . rand(100,1000000))
];
}

}

65 changes: 65 additions & 0 deletions app/Http/Controllers/Api/CategoriesController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

namespace App\Http\Controllers\Api;

use App\Category;
use App\Job;
use App\Http\Controllers\Controller;
use App\Http\Resources\JobCollection;
use Illuminate\Http\Request;

class CategoriesController extends Controller
{
public function get()
{
return response()->json([
'categories' => Category::withCount('jobs')->orderBy('name', 'ASC')->get(),
],200);
}

public function getJobs(Category $category)
{
$collection = new JobCollection(
Job::where(['category_id' => $category->id])->paginate($this->results_per_page)
);

return response()->json([
'collection' => $collection,
'category' => $category,
],200);
}

public function store(Request $request, Category $category)
{
$cat = $category->create($this->categoryData($request->name));

return response()->json([
'category' => $cat
], 200);
}

public function update(Request $request, Category $category)
{
$category->update($this->categoryData($request->name));

return response()->json([
'category' => $category
], 200);
}

private function categoryData($name)
{
return [
'name' => $name,
'slug' => str_slug($name)
];
}

public function destroy(Category $category)
{
$category->delete();
return response([
'category' => $category
], 202);
}
}
Loading

0 comments on commit a412039

Please sign in to comment.