Venues Administration ready for Test
This commit is contained in:
parent
11e873e83a
commit
76f12aecd5
|
|
@ -35,34 +35,40 @@ class VenueCrudController extends CrudController
|
|||
|
||||
// TODO: remove setFromDb() and manually define Fields and Columns
|
||||
$this->crud->addColumns([
|
||||
['name'=>'venue_name','type'=>'text','label'=>'Venue Name En'],
|
||||
// ['name'=>'venue_name','type'=>'text','label'=>'Venue Name En'],
|
||||
['name'=>'venue_name_ru','type'=>'text','label'=>'Venue Name Ru'],
|
||||
['name'=>'venue_name_tk','type'=>'text','label'=>'Venue Name Tk'],
|
||||
['name'=>'active','type'=>'boolean','label'=>'Active']
|
||||
]);
|
||||
|
||||
$this->crud->addFields([
|
||||
['name'=>'venue_name','type'=>'text','label'=>'Venue Name En'],
|
||||
['name'=>'venue_name_ru','type'=>'text','label'=>'Venue Name Ru'],
|
||||
['name'=>'venue_name_tk','type'=>'text','label'=>'Venue Name Tk'],
|
||||
// ['name'=>'venue_name','type'=>'text','label'=>'Venue Name En'],
|
||||
['name'=>'venue_name_ru','type'=>'text','label'=>'Venue Name','tab' => 'Russian'],
|
||||
['name'=>'venue_name_tk','type'=>'text','label'=>'Venue Name','tab' => 'Turkmen'],
|
||||
['name'=>'description_ru','type'=>'text','label'=>'Description', 'tab' => 'Russian'],
|
||||
['name'=>'description_tk','type'=>'text','label'=>'Description', 'tab' => 'Turkmen'],
|
||||
[ // Address
|
||||
'name' => 'address',
|
||||
'label' => 'Address',
|
||||
'type' => 'address_google',
|
||||
// optional
|
||||
'store_as_json' => true
|
||||
'store_as_json' => true,
|
||||
'tab' => 'General'
|
||||
],
|
||||
['name'=>'images','type'=>'upload_multiple','label'=>'Suratlar',
|
||||
'upload' => true, 'disk' => config('filesystems.default'), 'tab' => 'Suratlar'],
|
||||
[ // image
|
||||
'label' => "Seats Image",
|
||||
'name' => "seats_image",
|
||||
'type' => 'image',
|
||||
'upload' => true,
|
||||
'tab' => 'Suratlar',
|
||||
// 'crop' => true, // set to true to allow cropping, false to disable
|
||||
// 'aspect_ratio' => 1, // ommit or set to 0 to allow any aspect ratio
|
||||
// 'disk' => 's3_bucket', // in case you need to show images from a different disk
|
||||
'prefix' => 'user_content/' // in case your db value is only the file name (no path), you can use this to prepend your path to the image src (in HTML), before it's shown to the user;
|
||||
],
|
||||
['name'=>'active','type'=>'checkbox','label'=>'Active']
|
||||
['name'=>'active','type'=>'checkbox','label'=>'Active','tab' => 'General']
|
||||
]);
|
||||
|
||||
// add asterisk for fields that are required in VenueRequest
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class Venue extends Model
|
|||
| GLOBAL VARIABLES
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
protected $casts = [ 'address' => 'array'];
|
||||
protected $casts = [ 'address' => 'array','images' => 'array'];
|
||||
protected $table = 'venues';
|
||||
// protected $primaryKey = 'id';
|
||||
public $timestamps = false;
|
||||
|
|
@ -26,6 +26,8 @@ class Venue extends Model
|
|||
'venue_name_ru',
|
||||
'venue_name_tk',
|
||||
'venue_name_full',
|
||||
'description_ru',
|
||||
'description_tk',
|
||||
'location_address',
|
||||
'location_address_line_1',
|
||||
'location_address_line_2',
|
||||
|
|
@ -39,11 +41,13 @@ class Venue extends Model
|
|||
'location_google_place_id',
|
||||
'seats_image',
|
||||
'active',
|
||||
'address'
|
||||
'address',
|
||||
'images',
|
||||
];
|
||||
// protected $hidden = [];
|
||||
// protected $dates = [];
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| FUNCTIONS
|
||||
|
|
@ -55,6 +59,12 @@ class Venue extends Model
|
|||
static::deleting(function($obj) {
|
||||
$disk = config('filesystems.default');
|
||||
\Storage::disk($disk)->delete($obj->seats_image);
|
||||
|
||||
if (count((array)$obj->images)) {
|
||||
foreach ($obj->images as $file_path) {
|
||||
\Storage::disk('uploads')->delete($file_path);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -122,4 +132,45 @@ class Venue extends Model
|
|||
$this->attributes[$attribute_name] = $public_destination_path.'/'.$filename;
|
||||
}
|
||||
}
|
||||
|
||||
public function uploadMultipleFilesToDisk($value, $attribute_name, $disk, $destination_path)
|
||||
{
|
||||
$request = \Request::instance();
|
||||
$attribute_value = (array) $this->{$attribute_name};
|
||||
$files_to_clear = $request->get('clear_'.$attribute_name);
|
||||
// if a file has been marked for removal,
|
||||
// delete it from the disk and from the db
|
||||
if ($files_to_clear) {
|
||||
$attribute_value = (array) $this->{$attribute_name};
|
||||
foreach ($files_to_clear as $key => $filename) {
|
||||
\Storage::disk($disk)->delete($filename);
|
||||
$attribute_value = array_where($attribute_value, function ($value, $key) use ($filename) {
|
||||
return $value != $filename;
|
||||
});
|
||||
}
|
||||
}
|
||||
// if a new file is uploaded, store it on disk and its filename in the database
|
||||
if ($request->hasFile($attribute_name)) {
|
||||
foreach ($request->file($attribute_name) as $file) {
|
||||
if ($file->isValid()) {
|
||||
// 1. Generate a new file name
|
||||
$new_file_name = $file->getClientOriginalName();
|
||||
// 2. Move the new file to the correct path
|
||||
$file_path = $file->storeAs($destination_path, $new_file_name, $disk);
|
||||
// 3. Add the public path to the database
|
||||
$attribute_value[] = $file_path;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->attributes[$attribute_name] = json_encode($attribute_value);
|
||||
}
|
||||
|
||||
public function setImagesAttribute($value)
|
||||
{
|
||||
$attribute_name = "images";
|
||||
$disk = config('filesystems.default');
|
||||
$destination_path = "venues/Images";
|
||||
|
||||
$this->uploadMultipleFilesToDisk($value, $attribute_name, $disk, $destination_path);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AlterAddDescriptionToVenuesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('venues', function (Blueprint $table) {
|
||||
$table->text('description_ru')->nullable();
|
||||
$table->text('description_tk')->nullable();
|
||||
$table->longText('images')->nullable();
|
||||
$table->string('venue_name')->nullable(true)->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('venues', function (Blueprint $table) {
|
||||
$table->dropColumn('description_ru');
|
||||
$table->dropColumn('description_tk');
|
||||
$table->dropColumn('images');
|
||||
$table->string('venue_name')->nullable(false)->change();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -66,7 +66,7 @@
|
|||
@if((int)ceil($order_item->unit_price) == 0)
|
||||
БЕСПЛАТНО
|
||||
@else
|
||||
{{money(($order_item->unit_price) * ($order_item->quantity), $order->event->currency)}}
|
||||
{{money($order_item->unit_total, $order->event->currency)}}
|
||||
@endif
|
||||
|
||||
</td>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title>
|
||||
@section('subject')
|
||||
Attendize.com Email
|
||||
Bilettm.com Email
|
||||
@show
|
||||
</title>
|
||||
</head>
|
||||
|
|
@ -15,10 +15,10 @@
|
|||
<table class="body-wrap" style="background-color: #f7f7f7;margin: 0;padding: 20px;font-family: "Helvetica Neue", "Helvetica", Helvetica, Arial, sans-serif;font-size: 100%;line-height: 1.6;width: 100%">
|
||||
<tr style="margin: 0;padding: 0;font-family: "Helvetica Neue", "Helvetica", Helvetica, Arial, sans-serif;font-size: 100%;line-height: 1.6">
|
||||
<td style="margin: 0;padding: 0;font-family: "Helvetica Neue", "Helvetica", Helvetica, Arial, sans-serif;font-size: 100%;line-height: 1.6"></td>
|
||||
<td class="container" bgcolor="#FFFFFF" style="margin: 0 auto !important;padding: 0;font-family: "Helvetica Neue", "Helvetica", Helvetica, Arial, sans-serif;font-size: 100%;line-height: 1.6;border: 1px solid #f0f0f0;display: block !important;max-width: 600px !important;clear: both !important">
|
||||
<td class="container" bgcolor="#FFFFFF" style="margin: 0 auto !important;padding: 0;font-family: "Helvetica Neue", "Helvetica", Helvetica, Arial, sans-serif;font-size: 100%;line-height: 1.6;border: 1px solid #f0f0f0;display: block !important;max-width: 800px !important;clear: both !important">
|
||||
|
||||
<!-- content -->
|
||||
<div class="content" style="color: #888;margin: 0 auto;padding: 20px;font-family: "Helvetica Neue", "Helvetica", Helvetica, Arial, sans-serif;font-size: 100%;line-height: 1.6;max-width: 600px;display: block">
|
||||
<div class="content" style="color: #888;margin: 0 auto;padding: 20px;font-family: "Helvetica Neue", "Helvetica", Helvetica, Arial, sans-serif;font-size: 100%;line-height: 1.6;max-width: 700px;display: block">
|
||||
<table style="margin: 0;padding: 0;font-family: "Helvetica Neue", "Helvetica", Helvetica, Arial, sans-serif;font-size: 100%;line-height: 1.6;width: 100%">
|
||||
<tr style="margin: 0;padding: 0;font-family: "Helvetica Neue", "Helvetica", Helvetica, Arial, sans-serif;font-size: 100%;line-height: 1.6">
|
||||
<td style="text-align: center;padding: 10px;margin: 0;font-family: "Helvetica Neue", "Helvetica", Helvetica, Arial, sans-serif;font-size: 100%;line-height: 1.6">
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
@extends('en.Emails.Layouts.Master')
|
||||
@extends('tk.Emails.Layouts.Master')
|
||||
|
||||
@section('message_content')
|
||||
Salam!<br><br>
|
||||
|
|
@ -20,7 +20,7 @@ Sargydyň poçtasy: <b>{{$order->email}}</b><br>
|
|||
<a href="{!! route('downloadCalendarIcs', ['event_id' => $order->event->id]) !!}">Add To Calendar</a>
|
||||
<h3>Sargydyň petekleri</h3>
|
||||
<div style="padding:10px; background: #F9F9F9; border: 1px solid #f1f1f1;">
|
||||
<table style="width:100%; margin:10px;">
|
||||
<table style="width:100%;border-collapse: collapse;" border="1" cellpadding="5">
|
||||
<tr>
|
||||
<td>
|
||||
<b>Petek</b>
|
||||
|
|
@ -66,7 +66,7 @@ Sargydyň poçtasy: <b>{{$order->email}}</b><br>
|
|||
@if((int)ceil($order_item->unit_price) == 0)
|
||||
MUGT
|
||||
@else
|
||||
{{money(($order_item->unit_price + $order_item->unit_booking_fee) * ($order_item->quantity), $order->event->currency)}}
|
||||
{{money($order_item->unit_total, $order->event->currency)}}
|
||||
@endif
|
||||
|
||||
</td>
|
||||
|
|
|
|||
Loading…
Reference in New Issue