Exemple #1
0
 protected function sendMail($event, $action, $is_user_mail, $is_admin_mail)
 {
     $mailer = new PaymentMail();
     $role = Role::whereName('root')->firstOrFail();
     $admin = $role->admins->first();
     $data = ['amount' => $event->order->amount, 'currency' => setting('currency'), 'gateway' => $event->actor];
     if ($is_admin_mail) {
         $mailer->admin()->{$action}($admin, $data);
     }
 }
Exemple #2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $role = Role::whereName('user')->firstOrFail();
     $subscription = Subscription::whereIsDefault(1)->first();
     $user = $role->users()->create(['name' => 'ZEDx demo', 'email' => '*****@*****.**', 'avatar' => 'zedx.png', 'phone' => '0606060606', 'is_phone' => true, 'is_validate' => true, 'subscription_id' => $subscription->id, 'subscribed_at' => Carbon::now()->format('d/m/Y'), 'subscription_expired_at' => $subscription->days >= 9999 ? null : Carbon::now()->addDays($subscription->days + 1), 'password' => 'password']);
     event(new UserWasCreated($user, 'ZEDx'));
     $users = factory(User::class, 3)->create();
     foreach ($users as $user) {
         event(new UserWasCreated($user, 'ZEDx'));
     }
 }
 protected function sendMail($event, $action, $is_user_mail, $is_admin_mail)
 {
     $mailer = new SubscriptionMail();
     $role = Role::whereName('root')->firstOrFail();
     $admin = $role->admins->first();
     $data = ['user' => $this->user, 'subscription' => $event->subscription];
     if ($is_admin_mail) {
         $mailer->admin()->{$action}($admin, $data);
     }
     if ($is_user_mail) {
         $mailer->user()->{$action}($this->user, $data);
     }
 }
Exemple #4
0
 protected function sendMail($event, $action, $is_user_mail, $is_admin_mail)
 {
     $mailer = new AdtypeMail();
     $role = Role::whereName('root')->firstOrFail();
     $admin = $role->admins->first();
     $user = $event->order->user;
     $data = ['user' => $user, 'adtype' => $event->adtype, 'number' => $event->order->quantity];
     if ($is_admin_mail) {
         $mailer->admin()->{$action}($admin, $data);
     }
     if ($is_user_mail) {
         $mailer->user()->{$action}($user, $data);
     }
 }
Exemple #5
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(CreateUserRequest $request)
 {
     $admin = Auth::guard('admin')->user();
     $subscription = Subscription::findOrFail($request->get('subscription_id'));
     $role = Role::whereName('user')->firstOrFail();
     $inputs = $request->all();
     if (!isset($inputs['phone']) || empty($inputs['phone'])) {
         $inputs['is_phone'] = false;
     }
     $user = new User();
     $user->fill($inputs);
     $user->subscription_id = $subscription->id;
     $user->role_id = $role->id;
     $user->subscribed_at = $request->get('subscribed_at');
     $user->subscription_expired_at = $subscription->days >= 9999 ? null : Carbon::createFromFormat('d/m/Y', $user->subscribed_at)->addDays($subscription->days + 1);
     $adtypes = $request->get('adtypes', []);
     event(new UserWillBeCreated($user, $admin, $adtypes));
     $user->save();
     $user->adtypes()->sync($adtypes);
     event(new UserWasCreated($user, $admin));
     return redirect()->route('zxadmin.user.edit', $user->id);
 }
Exemple #6
0
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look.
|
*/
use Carbon\Carbon;
use ZEDx\Models\Role;
use ZEDx\Models\Subscription;
use ZEDx\Models\User;
$factory->define(User::class, function (Faker\Generator $faker) {
    return ['name' => $faker->name, 'email' => $faker->email, 'is_validate' => true, 'role_id' => function () {
        return Role::whereName('user')->firstOrFail()->id;
    }, 'subscription_id' => function () {
        return Subscription::whereIsDefault(1)->first()->id;
    }, 'subscribed_at' => Carbon::now()->format('d/m/Y'), 'subscription_expired_at' => function () {
        $subscription = Subscription::whereIsDefault(1)->first();
        return $subscription->days >= 9999 ? null : Carbon::now()->addDays($subscription->days + 1);
    }, 'password' => str_random(10), 'remember_token' => str_random(10)];
});
$factory->define(ZEDx\Models\Admin::class, function (Faker\Generator $faker) {
    return ['name' => $faker->name, 'email' => $faker->email, 'password' => bcrypt(str_random(10)), 'remember_token' => str_random(10)];
});
$factory->define(ZEDx\Models\Subscription::class, function (Faker\Generator $faker) {
    return ['title' => $faker->word, 'description' => $faker->sentence, 'days' => $faker->randomNumber(3), 'is_default' => 0, 'price' => $faker->randomNumber(2)];
});
$factory->define(ZEDx\Models\Adtype::class, function (Faker\Generator $faker) {
    return ['title' => $faker->word, 'is_headline' => $faker->boolean(), 'can_renew' => $faker->boolean(), 'can_edit' => $faker->boolean(), 'can_add_pic' => $faker->boolean(), 'can_update_pic' => $faker->boolean(), 'nbr_pic' => $faker->randomNumber(1), 'nbr_days' => $faker->randomNumber(3), 'can_add_video' => $faker->boolean(), 'nbr_video' => $faker->randomNumber(1), 'can_update_video' => $faker->boolean(), 'price' => $faker->randomNumber(2)];
Exemple #7
0
 /**
  * Store new user.
  *
  * @param array      $data
  * @param Admin/User $actor
  *
  * @return array
  */
 public function store(array $data, $actor, $provider = false)
 {
     $subscription = Subscription::whereIsDefault(1)->firstOrFail();
     $role = Role::whereName('user')->firstOrFail();
     $adtypes = [];
     foreach ($subscription->adtypes as $adtype) {
         $adtypes[$adtype->id] = ['number' => $adtype->pivot->number];
     }
     if (!isset($data['phone']) || empty($data['phone'])) {
         $data['is_phone'] = false;
     }
     $user = new User();
     $user->fill($data);
     if ($provider) {
         $user->is_validate = $data['is_validate'];
     }
     $user->subscription_id = $subscription->id;
     $user->role_id = $role->id;
     $user->subscribed_at = Carbon::now()->format('d/m/Y');
     $user->subscription_expired_at = $subscription->days >= 9999 ? null : Carbon::createFromFormat('d/m/Y', $user->subscribed_at)->addDays($subscription->days + 1);
     event(new UserWillBeCreated($user, $actor, $adtypes));
     $user->save();
     $user->adtypes()->sync($adtypes);
     event(new UserWasCreated($user, $actor));
     return ['user' => $user];
 }
Exemple #8
0
 protected function sendMail($event, $action, $is_user_mail, $is_admin_mail)
 {
     $mailer = new AdMail();
     $role = Role::whereName('root')->firstOrFail();
     $admin = $role->admins->first();
     $data = ['ad' => $event->ad];
     if ($is_admin_mail) {
         $mailer->admin()->{$action}($admin, $data);
     }
     if ($is_user_mail) {
         $mailer->user()->{$action}($event->ad->user, $data);
     }
 }
Exemple #9
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Role::insert([['name' => 'root', 'display_name' => 'Root', 'description' => 'Use this account with extreme caution. When using this account it is possible to cause irreversible damage to the system.', 'is_visible' => false], ['name' => 'system', 'display_name' => 'System', 'description' => 'This role is reserved to systems actions.', 'is_visible' => false], ['name' => 'administrator', 'display_name' => 'Administrator', 'description' => 'Full access to create, edit, and update everything.', 'is_visible' => true], ['name' => 'manager', 'display_name' => 'Manager', 'description' => 'Ability to manage ads.', 'is_visible' => true], ['name' => 'translator', 'display_name' => 'Translator', 'description' => 'Ability to translate the website.', 'is_visible' => true], ['name' => 'user', 'display_name' => 'User', 'description' => 'Ability to add ads.', 'is_visible' => false]]);
 }
Exemple #10
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $role = Role::whereName('root')->first();
     $role->admins()->create(['name' => 'Administrator', 'email' => '*****@*****.**', 'password' => 'password']);
 }