Commit fcad6cb7 by Vladislav

#19461 Страница настройки целевых аккаунтов. (fix update edit)

1 parent 3ade173c
...@@ -153,7 +153,7 @@ class TokensController extends Controller ...@@ -153,7 +153,7 @@ class TokensController extends Controller
return Redirect::back(); return Redirect::back();
} }
$city->token()->associate($token->getKey()); $token->cities()->save($city);
return Redirect::route('token.edit', $token->getKey())->with('success', 'City added.'); return Redirect::route('token.edit', $token->getKey())->with('success', 'City added.');
} }
...@@ -164,14 +164,15 @@ class TokensController extends Controller ...@@ -164,14 +164,15 @@ class TokensController extends Controller
return Redirect::back(); return Redirect::back();
} }
$city = $token->cities()->find($city); $city = $token->cities()->where($city->getKeyName(), $city->getKey())
->first();
if (!$city) { if (!$city) {
return Redirect::back(); return Redirect::back();
} }
$city->update([ $city->update([
'updated' => !!request('updated'), 'update' => !!request('updated'),
]); ]);
return Redirect::route('token.edit', $token->getKey())->with('success', 'City updated.'); return Redirect::route('token.edit', $token->getKey())->with('success', 'City updated.');
......
...@@ -8,6 +8,10 @@ class Dictionary extends Model ...@@ -8,6 +8,10 @@ class Dictionary extends Model
{ {
CONST CITY = 'City'; CONST CITY = 'City';
protected $fillable = [
'update',
];
protected $casts = [ protected $casts = [
'update' => 'boolean', 'update' => 'boolean',
]; ];
......
...@@ -32,8 +32,8 @@ ...@@ -32,8 +32,8 @@
<span class="px-6 py-4 flex items-center focus:text-indigo-500"> {{ city.name }} </span> <span class="px-6 py-4 flex items-center focus:text-indigo-500"> {{ city.name }} </span>
</td> </td>
<td class="border-t"> <td class="border-t">
<input :checked="city.pivot.updated" <input :checked="city.update"
@change="cityUpdated(city.id, !city.pivot.updated)" @change="cityUpdated(city.id, !city.update)"
type="checkbox" type="checkbox"
> >
</td> </td>
...@@ -106,7 +106,6 @@ export default { ...@@ -106,7 +106,6 @@ export default {
this.$emit('delete', id) this.$emit('delete', id)
}, },
cityUpdated(id, updated) { cityUpdated(id, updated) {
console.log(this.token_cities);
this.$emit('updated', id, updated) this.$emit('updated', id, updated)
}, },
campaignUpdated(id, updated) { campaignUpdated(id, updated) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!