31 changed files with 24 additions and 351 deletions
-
36app/Entities/Agencies/Agency.php
-
13app/Entities/Payments/Payment.php
-
6app/Entities/Projects/Project.php
-
5app/Entities/Users/User.php
-
9app/Entities/Users/UsersRepository.php
-
8app/Http/Controllers/AuthController.php
-
2app/Http/Controllers/Partners/CustomersController.php
-
2app/Http/Controllers/Partners/VendorsController.php
-
35app/Http/Controllers/Users/AgencyController.php
-
4app/Http/Requests/Accounts/RegisterRequest.php
-
17app/Policies/AgencyPolicy.php
-
6app/Policies/UserPolicy.php
-
9app/Providers/AuthServiceProvider.php
-
17app/Traits/OwnedByAgency.php
-
37database/migrations/2017_11_02_175711_create_agency_workers_table.php
-
33resources/lang/id/agency.php
-
1resources/lang/id/auth.php
-
12resources/views/auth/register.blade.php
-
2resources/views/layouts/partials/sidebar.blade.php
-
5resources/views/pages/partials/dashboard-nav-tabs.blade.php
-
12resources/views/payments/pdf.blade.php
-
19routes/web/account.php
-
2tests/Feature/Auth/MemberLoginTest.php
-
6tests/Feature/Auth/MemberRegistrationTest.php
-
4tests/Feature/ManageFeaturesTest.php
-
15tests/Feature/Users/ManageUsersTest.php
-
35tests/Feature/Users/UserProfileTest.php
-
2tests/TestCase.php
-
11tests/Unit/Models/UserTest.php
-
7tests/Unit/Policies/ProjectPolicyTest.php
-
3tests/Unit/Policies/UserPolicyTest.php
@ -1,36 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace App\Entities\Agencies; |
|||
|
|||
use App\Entities\Users\User; |
|||
use Illuminate\Database\Eloquent\Model; |
|||
|
|||
class Agency extends Model |
|||
{ |
|||
protected $fillable = ['name', 'email', 'address', 'phone', 'website', 'owner_id']; |
|||
|
|||
public function owner() |
|||
{ |
|||
return $this->belongsTo('App\Entities\Users\User'); |
|||
} |
|||
|
|||
public function projects() |
|||
{ |
|||
return $this->hasMany('App\Entities\Projects\Project', 'owner_id'); |
|||
} |
|||
|
|||
public function workers() |
|||
{ |
|||
return $this->belongsToMany('App\Entities\Users\User', 'agency_workers', 'agency_id', 'worker_id'); |
|||
} |
|||
|
|||
public function addWorker(User $worker) |
|||
{ |
|||
$this->workers()->attach($worker); |
|||
} |
|||
|
|||
public function removeWorker(User $worker) |
|||
{ |
|||
$this->workers()->detach($worker); |
|||
} |
|||
} |
|||
@ -1,35 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace App\Http\Controllers\Users; |
|||
|
|||
use App\Http\Controllers\Controller; |
|||
|
|||
class AgencyController extends Controller |
|||
{ |
|||
public function show() |
|||
{ |
|||
$agency = auth()->user()->agency; |
|||
return view('users.agency.show', compact('agency')); |
|||
} |
|||
|
|||
public function edit() |
|||
{ |
|||
return view('users.agency.edit'); |
|||
} |
|||
|
|||
public function update() |
|||
{ |
|||
$agency = auth()->user()->agency; |
|||
|
|||
$agency->name = request('name'); |
|||
$agency->email = request('email'); |
|||
$agency->website = request('website'); |
|||
$agency->address = request('address'); |
|||
$agency->phone = request('phone'); |
|||
$agency->save(); |
|||
|
|||
flash(trans('agency.updated'), 'success'); |
|||
|
|||
return redirect()->route('users.agency.show'); |
|||
} |
|||
} |
|||
@ -1,17 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace App\Policies; |
|||
|
|||
use App\Entities\Agencies\Agency; |
|||
use App\Entities\Users\User; |
|||
use Illuminate\Auth\Access\HandlesAuthorization; |
|||
|
|||
class AgencyPolicy |
|||
{ |
|||
use HandlesAuthorization; |
|||
|
|||
public function manage(User $user, Agency $agency) |
|||
{ |
|||
return $user->id == $agency->owner_id; |
|||
} |
|||
} |
|||
@ -1,17 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace App\Traits; |
|||
|
|||
use Illuminate\Database\Eloquent\Builder; |
|||
|
|||
trait OwnedByAgency |
|||
{ |
|||
public static function bootOwnedByAgency() |
|||
{ |
|||
static::addGlobalScope('by_owner', function (Builder $builder) { |
|||
if (auth()->user() && auth()->user()->agency) { |
|||
$builder->where('owner_id', auth()->user()->agency->id); |
|||
} |
|||
}); |
|||
} |
|||
} |
|||
@ -1,37 +0,0 @@ |
|||
<?php |
|||
|
|||
use Illuminate\Database\Migrations\Migration; |
|||
use Illuminate\Database\Schema\Blueprint; |
|||
use Illuminate\Support\Facades\Schema; |
|||
|
|||
class CreateAgencyWorkersTable extends Migration |
|||
{ |
|||
/** |
|||
* Run the migrations. |
|||
* |
|||
* @return void |
|||
*/ |
|||
public function up() |
|||
{ |
|||
Schema::create('agency_workers', function (Blueprint $table) { |
|||
$table->increments('id'); |
|||
$table->unsignedInteger('agency_id'); |
|||
$table->unsignedInteger('worker_id'); |
|||
$table->timestamps(); |
|||
|
|||
$table->unique(['agency_id', 'worker_id'], 'agency_worker_unique'); |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Reverse the migrations. |
|||
* |
|||
* @return void |
|||
*/ |
|||
public function down() |
|||
{ |
|||
Schema::table('agency_workers', function (Blueprint $table) { |
|||
//
|
|||
}); |
|||
} |
|||
} |
|||
@ -1,33 +0,0 @@ |
|||
<?php |
|||
|
|||
return [ |
|||
// Labels
|
|||
'agency' => 'Agensi', |
|||
'list' => 'Daftar Agensi', |
|||
'search' => 'Cari Agensi', |
|||
'not_found' => 'Agensi tidak ditemukan', |
|||
'empty' => 'Belum ada Agensi', |
|||
'back_to_show' => 'Kembali ke detail Agensi', |
|||
'back_to_index' => 'Kembali ke daftar Agensi', |
|||
|
|||
// Actions
|
|||
'create' => 'Input Agensi Baru', |
|||
'created' => 'Input Agensi baru telah berhasil.', |
|||
'show' => 'Detail Agensi', |
|||
'edit' => 'Edit Agensi', |
|||
'update' => 'Update Agensi', |
|||
'updated' => 'Update data Agensi telah berhasil.', |
|||
'delete' => 'Hapus Agensi', |
|||
'delete_confirm' => 'Anda yakin akan menghapus Agensi ini?', |
|||
'deleted' => 'Hapus data Agensi telah berhasil.', |
|||
'undeleted' => 'Data Agensi gagal dihapus.', |
|||
'undeleteable' => 'Data Agensi tidak dapat dihapus.', |
|||
|
|||
// Attributes
|
|||
'name' => 'Nama Agensi', |
|||
'email' => 'Email Agensi', |
|||
'website' => 'Website Agensi', |
|||
'address' => 'Alamat Agensi', |
|||
'phone' => 'Telp. Agensi', |
|||
'owner' => 'Pemilik Agensi', |
|||
]; |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue