Browse Source

Nobody had ever created a function like this one before.

pull/2/head
Mohammad Akbari 4 years ago
parent
commit
c96af7fd78
Signed by: akbarjimi GPG Key ID: 55726AEFECE5E683
  1. 3
      app/Models/Activity.php
  2. 4
      app/Models/Business.php
  3. 2
      app/Models/Comment.php
  4. 2
      app/Models/Cost.php
  5. 2
      app/Models/File.php
  6. 2
      app/Models/Fingerprint.php
  7. 2
      app/Models/Model.php
  8. 4
      app/Models/Project.php
  9. 0
      app/Models/ReportableRelation.php
  10. 5
      app/Models/Sprint.php
  11. 4
      app/Models/Status.php
  12. 5
      app/Models/System.php
  13. 4
      app/Models/Tag.php
  14. 2
      app/Models/TagTask.php
  15. 18
      app/Models/Task.php
  16. 4
      app/Models/Transaction.php
  17. 4
      app/Models/User.php
  18. 6
      app/Models/Work.php
  19. 3
      app/Models/Workflow.php
  20. 28
      app/Utilities/Helpers/enum.php
  21. 4
      composer.json
  22. 3
      database/factories/BusinessFactory.php
  23. 2
      database/factories/CostFactory.php
  24. 2
      database/factories/FileFactory.php
  25. 3
      database/factories/FingerprintFactory.php
  26. 5
      database/factories/ProjectFactory.php
  27. 4
      database/factories/SprintflowFactory.php
  28. 4
      database/factories/SystemFactory.php
  29. 2
      database/factories/TagFactory.php
  30. 2
      database/factories/TaskFactory.php
  31. 2
      database/factories/TransactionFactory.php
  32. 2
      database/factories/UserFactory.php
  33. 3
      database/factories/WorkFactory.php
  34. 4
      database/factories/WorkflowFactory.php
  35. 2
      database/factories/WorkstatusFactory.php
  36. 12
      database/seeds/BusinessSeeder.php
  37. 2
      database/seeds/CostSeeder.php
  38. 3
      database/seeds/DatabaseSeeder.php
  39. 13
      database/seeds/FileSeeder.php
  40. 6
      database/seeds/ProjectSeeder.php
  41. 2
      database/seeds/SprintSeeder.php
  42. 7
      database/seeds/TagSeeder.php
  43. 4
      database/seeds/TaskSeeder.php
  44. 2
      database/seeds/TransactionSeeder.php
  45. 6
      database/seeds/UserSeeder.php
  46. 2
      database/seeds/WorkSeeder.php
  47. 5
      database/seeds/WorkflowSeeder.php
  48. 10
      routes/api.php

3
app/Models/Activity.php

@ -2,8 +2,7 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use App\Models\Model;
class Activity extends Model
{

4
app/Models/Business.php

@ -3,8 +3,8 @@
namespace App\Models;
use App\File;
use App\SoftDeletes;
use App\HiLib\Models\Model;
use App\Models\Model;
use App\Models\SoftDeletes;
use Illuminate\Validation\Rule;
use Illuminate\Http\UploadedFile;
use Spatie\MediaLibrary\HasMedia;

2
app/Models/Comment.php

@ -2,8 +2,8 @@
namespace App\Models;
use App\Models\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Comment extends Model
{

2
app/Models/Cost.php

@ -2,7 +2,7 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use App\Models\Model;
class Cost extends Model
{

2
app/Models/File.php

@ -2,7 +2,7 @@
namespace App\Models;
use App\HiLib\Models\Model;
use App\Models\Model;
use Illuminate\Support\Facades\Storage;
class File extends Model

2
app/Models/Fingerprint.php

@ -2,7 +2,7 @@
namespace App\Models;
use App\HiLib\Models\Model;
use App\Models\Model;
class Fingerprint extends Model
{

2
app/Utilities/Models/Model.php → app/Models/Model.php

@ -1,6 +1,6 @@
<?php
namespace App\Utilities\Models;
namespace App\Models;
use Anik\Amqp\Exchange;
use Anik\Amqp\Facades\Amqp;

4
app/Models/Project.php

@ -3,8 +3,8 @@
namespace App\Models;
use App\File;
use App\SoftDeletes;
use App\HiLib\Models\Model;
use App\Models\Model;
use App\Models\SoftDeletes;
use Illuminate\Validation\Rule;
use Illuminate\Http\UploadedFile;
use Spatie\MediaLibrary\HasMedia;

0
app/Utilities/Models/ReportableRelation.php → app/Models/ReportableRelation.php

5
app/Models/Sprint.php

@ -2,10 +2,7 @@
namespace App\Models;
use App\HiLib\Models\Model;
use Illuminate\Validation\Rule;
use Illuminate\Database\Eloquent\SoftDeletes;
use App\Models\Model;
class Sprint extends Model
{

4
app/Models/Status.php

@ -2,9 +2,7 @@
namespace App\Models;
use App\HiLib\Models\Model;
use Illuminate\Validation\Rule;
use App\Models\Model;
class Status extends Model
{

5
app/Models/System.php

@ -2,10 +2,7 @@
namespace App\Models;
use App\HiLib\Models\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Validation\Rule;
use App\Models\Model;
class System extends Model
{

4
app/Models/Tag.php

@ -2,9 +2,7 @@
namespace App\Models;
use App\HiLib\Models\Model;
use App\Scopes\BusinessScope;
use App\Models\Model;
class Tag extends Model
{

2
app/Models/TagTask.php

@ -2,7 +2,7 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use App\Models\Model;
class TagTask extends Model
{

18
app/Models/Task.php

@ -2,20 +2,20 @@
namespace App\Models;
use App\Models\Business;
use App\Models\Comment;
use App\HiLib\Models\ReportableRelation;
use App\Models\Project;
use Carbon\Carbon;
use App\Models\Tag;
use App\Models\TagTask;
use App\Models\User;
use App\Models\Work;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use App\Models\Model;
use App\Models\Comment;
use App\Models\Project;
use App\Models\TagTask;
use App\Models\Business;
use Illuminate\Validation\Rule;
use Illuminate\Support\Facades\DB;
use App\HiLib\Models\ReportableRelation;
use Illuminate\Validation\Rules\RequiredIf;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class Task extends Model
{

4
app/Models/Transaction.php

@ -2,9 +2,9 @@
namespace App\Models;
use App\HiLib\Models\Model;
use App\Utilities\Zarinpal\Laravel\Facade\Zarinpal;
use App\Models\Model;
use Illuminate\Support\Arr;
use App\Utilities\Zarinpal\Laravel\Facade\Zarinpal;
class Transaction extends Model
{

4
app/Models/User.php

@ -3,8 +3,8 @@
namespace App\Models;
use App\File;
use App\SoftDeletes;
use App\HiLib\Models\Model;
use App\Models\Model;
use App\Models\SoftDeletes;
use Illuminate\Validation\Rule;
use Illuminate\Http\UploadedFile;
use Spatie\MediaLibrary\HasMedia;

6
app/Models/Work.php

@ -2,11 +2,11 @@
namespace App\Models;
use App\Models\Task;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use App\Models\Task;
use App\Models\Model;
use Illuminate\Support\Facades\DB;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class Work extends Model
{

3
app/Models/Workflow.php

@ -2,8 +2,7 @@
namespace App\Models;
use App\HiLib\Models\Model;
use App\Scopes\BusinessScope;
use App\Models\Model;
class Workflow extends Model
{

28
app/Utilities/Helpers/enum.php

@ -1 +1,27 @@
<?php use Illuminate\Support\Arr; use Illuminate\Support\Str; if (! function_exists('enum')) { function enum($key) { // add a dot at the end of string to prevent undefined offset $key .= Str::of($key)->contains(".") ? "" : "."; // the first parameter of all enum keys are its filename [$filename, $key] = explode(".", $key, 2); // because we do not want to load the file every time use require $enums = require __DIR__ . "/../Enums/$filename.php"; // if the key that user provided not exists then null return $enums = Arr::get($enums, $key, null); // if enum null means that key not found throw_if($enums === null, 'Exception', "Undefined enum '{$key}'"); // if enum value is array its mean that user want to use it as collection return is_array($enums) ? collect($enums) : $enums; } }
<?php
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
if (! function_exists('enum')) {
function enum($key)
{
// add a dot at the end of string to prevent undefined offset
$key .= Str::of($key)->contains(".") ? "" : ".";
// the first parameter of all enum keys are its filename
[$filename, $key] = explode(".", $key, 2);
// because we do not want to load the file every time use require
$enums = require app_path("Enums/$filename.php");
// if the key that user provided not exists then null return
$enums = Arr::get($enums, $key, null);
// if enum null means that key not found
throw_if($enums === null, 'Exception', "Undefined enum '{$key}'");
// if enum value is array its mean that user want to use it as collection
return is_array($enums) ? collect($enums) : $enums;
}
}

4
composer.json

@ -56,6 +56,10 @@
},
"files": [
"app/Utilities/Helpers/index.php"
],
"classmap": [
"database/seeds",
"database/factories"
]
},
"autoload-dev": {

3
database/factories/BusinessFactory.php

@ -2,10 +2,9 @@
/** @var Factory $factory */
use App\Business;
use App\Models\Business;
use Illuminate\Support\Str;
use Faker\Generator as Faker;
use Illuminate\Database\Eloquent\Factory;
$factory->define(Business::class, function (Faker $faker) {
return [

2
database/factories/CostFactory.php

@ -2,8 +2,8 @@
/** @var Factory $factory */
use App\Cost;
use Carbon\Carbon;
use App\Models\Cost;
use Faker\Generator as Faker;
$factory->define(Cost::class, function (Faker $faker) {

2
database/factories/FileFactory.php

@ -2,7 +2,7 @@
/** @var Factory $factory */
use App\File;
use App\Models\File;
use Faker\Generator as Faker;
$factory->define(File::class, function (Faker $faker) {

3
database/factories/FingerprintFactory.php

@ -2,9 +2,8 @@
/** @var Factory $factory */
use App\Fingerprint;
use App\Models\Fingerprint;
use Faker\Factory as Faker;
use Illuminate\Database\Eloquent\Factory;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;

5
database/factories/ProjectFactory.php

@ -2,10 +2,9 @@
/** @var Factory $factory */
use App\Project;
use Faker\Generator as Faker;
use Illuminate\Database\Eloquent\Factory;
use App\Models\Project;
use Illuminate\Support\Str;
use Faker\Generator as Faker;
$factory->define(Project::class, function (Faker $faker) {
return [

4
database/factories/SprintflowFactory.php

@ -2,13 +2,13 @@
/** @var \Illuminate\Database\Eloquent\Factory $factory */
use App\Sprint;
use App\Models\Sprint;
use Faker\Generator as Faker;
$factory->define(Sprint::class, function (Faker $faker) {
return [
'business_id' => null,
'name' => $faker->randomElement(['scrum', 'printing',
'name' => $faker->randomElement(['scrum', 'printing',
'agile', 'develop', 'design', 'writing', 'seo', 'sale']),
'active' => rand(0, 1),
'description' => $faker->paragraph,

4
database/factories/SystemFactory.php

@ -2,10 +2,8 @@
/** @var Factory $factory */
use App\System;
use App\Models\System;
use Faker\Generator as Faker;
use Illuminate\Database\Eloquent\Factory;
use Illuminate\Support\Str;
$factory->define(System::class, function (Faker $faker) {
return [

2
database/factories/TagFactory.php

@ -2,8 +2,8 @@
/** @var \Illuminate\Database\Eloquent\Factory $factory */
use App\Tag;
use Faker\Factory;
use App\Models\Tag;
$faker = Factory::create('fa_IR');
$factory->define(Tag::class, function () use ($faker) {

2
database/factories/TaskFactory.php

@ -2,7 +2,7 @@
/** @var \Illuminate\Database\Eloquent\Factory $factory */
use App\Task;
use App\Models\Task;
use Faker\Generator as Faker;
$factory->define(Task::class, function (Faker $faker) {

2
database/factories/TransactionFactory.php

@ -3,7 +3,7 @@
/** @var Factory $factory */
use Carbon\Carbon;
use App\Transaction;
use App\Models\Transaction;
use Faker\Generator as Faker;
use Illuminate\Support\Facades\DB;

2
database/factories/UserFactory.php

@ -2,7 +2,7 @@
/** @var \Illuminate\Database\Eloquent\Factory $factory */
use App\User;
use App\Models\User;
use Faker\Generator as Faker;
$factory->define(User::class, function (Faker $faker) {

3
database/factories/WorkFactory.php

@ -2,8 +2,7 @@
/** @var \Illuminate\Database\Eloquent\Factory $factory */
use App\Work;
use Carbon\Carbon;
use App\Models\Work;
use Faker\Generator as Faker;
$factory->define(Work::class, function (Faker $faker) {

4
database/factories/WorkflowFactory.php

@ -2,13 +2,13 @@
/** @var \Illuminate\Database\Eloquent\Factory $factory */
use App\Workflow;
use App\Models\Workflow;
use Faker\Generator as Faker;
$factory->define(Workflow::class, function (Faker $faker) {
return [
'business_id' => null,
'name' => $faker->randomElement(['scrum', 'printing',
'name' => $faker->randomElement(['scrum', 'printing',
'agile', 'develop', 'design', 'writing', 'seo', 'sale']),
'desc' => $faker->sentences(1, true),
];

2
database/factories/WorkstatusFactory.php

@ -2,7 +2,7 @@
/** @var \Illuminate\Database\Eloquent\Factory $factory */
use App\Status;
use App\Models\Status;
use Faker\Generator as Faker;
$factory->define(Status::class, function (Faker $faker) {

12
database/seeds/BusinessSeeder.php

@ -1,13 +1,13 @@
<?php
use App\Business;
use App\User;
use App\Project;
use App\System;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Seeder;
use App\Models\User;
use App\Models\System;
use App\Models\Project;
use App\Models\Business;
use Illuminate\Support\Arr;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Illuminate\Database\Eloquent\Collection;
class BusinessSeeder extends Seeder
{

2
database/seeds/CostSeeder.php

@ -1,6 +1,6 @@
<?php
use App\Cost;
use App\Models\Cost;
use Illuminate\Database\Seeder;
class CostSeeder extends Seeder

3
database/seeds/DatabaseSeeder.php

@ -1,13 +1,11 @@
<?php
use App\File;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
public function run()
{
File::insert(factory(File::class, 500)->raw());
$this->call([
UserSeeder::class,
BusinessSeeder::class,
@ -18,7 +16,6 @@ class DatabaseSeeder extends Seeder
CostSeeder::class,
// ProjectSeeder::class,
// TaskSeeder::class,
// FileSeeder::class
]);
}
}

13
database/seeds/FileSeeder.php

@ -1,13 +0,0 @@
<?php
use App\File;
use Illuminate\Database\Seeder;
class FileSeeder extends Seeder
{
public function run()
{
factory(File::class, 500)->raw();
}
}

6
database/seeds/ProjectSeeder.php

@ -1,9 +1,9 @@
<?php
use App\Business;
use App\Project;
use Illuminate\Database\Seeder;
use App\Models\Project;
use App\Models\Business;
use Illuminate\Support\Arr;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class ProjectSeeder extends Seeder

2
database/seeds/SprintSeeder.php

@ -1,6 +1,6 @@
<?php
use App\Sprint;
use App\Models\Sprint;
use Illuminate\Database\Seeder;
class SprintSeeder extends Seeder

7
database/seeds/TagSeeder.php

@ -1,7 +1,6 @@
<?php
use App\Business;
use App\Tag;
use App\Models\Tag;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
@ -10,8 +9,8 @@ class TagSeeder extends Seeder
public function run()
{
$tags = [];
for ($business_id=1; $business_id <= 2000; $business_id++) {
for ($i=0; $i < rand(0, 10); $i++) {
for ($business_id=1; $business_id <= 2000; $business_id++) {
for ($i=0; $i < rand(0, 10); $i++) {
$tags[] = factory(Tag::class)->raw([
'business_id' => $business_id,
]);

4
database/seeds/TaskSeeder.php

@ -1,7 +1,7 @@
<?php
use App\TagTask;
use App\Task;
use App\Models\Task;
use App\Models\TagTask;
use Illuminate\Database\Seeder;
class TaskSeeder extends Seeder

2
database/seeds/TransactionSeeder.php

@ -1,6 +1,6 @@
<?php
use App\Transaction;
use App\Models\Transaction;
use Illuminate\Database\Seeder;
class TransactionSeeder extends Seeder

6
database/seeds/UserSeeder.php

@ -1,9 +1,9 @@
<?php
use App\User;
use App\Fingerprint;
use Illuminate\Database\Seeder;
use App\Models\User;
use App\Models\Fingerprint;
use Illuminate\Support\Arr;
use Illuminate\Database\Seeder;
class UserSeeder extends Seeder
{

2
database/seeds/WorkSeeder.php

@ -1,6 +1,6 @@
<?php
use App\Work;
use App\Models\Work;
use Illuminate\Database\Seeder;
class WorkSeeder extends Seeder

5
database/seeds/WorkflowSeeder.php

@ -1,8 +1,7 @@
<?php
use App\Business;
use App\Workflow;
use App\Status;
use App\Models\Status;
use App\Models\Workflow;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;

10
routes/api.php

@ -10,6 +10,9 @@ $router->group(['prefix' => 'actions'], function () use ($router) {
});
});
$router->get('/callback', 'CreditController@callback');
$router->get('/{transaction}/redirection', 'CreditController@redirection');
$router->group(['prefix' => 'auth'], function () use ($router) {
$router->get('/', 'AuthController@auth');
$router->delete('/', 'AuthController@delete');
@ -28,8 +31,6 @@ $router->group(['prefix' => 'auth'], function () use ($router) {
$router->get('google/callback', 'AuthController@handleGoogleCallback');
});
$router->group(['prefix' => 'businesses'], function () use ($router) {
$router->get('/', 'BusinessController@index');
$router->post('/', 'BusinessController@store');
@ -149,9 +150,6 @@ $router->group(['prefix' => 'businesses'], function () use ($router) {
});
});
$router->get('/callback', 'CreditController@callback');
$router->get('/{transaction}/redirection', 'CreditController@redirection');
$router->group(['prefix' => 'users'], function () use ($router) {
$router->get('/', 'UserController@index');
$router->get('/search', 'UserController@search');
@ -163,6 +161,7 @@ $router->group(['prefix' => 'users'], function () use ($router) {
$router->delete('/avatar', 'UserController@unSetAvatar');
});
});
$router->group([], function () use ($router) {
$router->post('/log', 'ActivityController@store');
$router->group(['prefix' => 'businesses/{business}', 'middleware' => ['auth', 'bindBusiness']], function ($router) {
@ -182,7 +181,6 @@ $router->group([], function () use ($router) {
$router->post('/watchers', 'TaskController@toggleWatcher');
$router->group(['prefix' => 'works'], function ($router) {
// $router->get('/', 'WorkController@index');
$router->post('/', 'WorkController@store');
$router->group(['prefix' => '{work}'], function ($router) {
$router->get('/', 'WorkController@show');

Loading…
Cancel
Save